-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for social profiles in facts list. Closes #250.
- Loading branch information
Showing
6 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/Bonsai/Areas/Admin/Views/Changesets/Facts/SocialProfilesFactModel.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@using Bonsai.Code.DomainModel.Facts.Models | ||
@using Impworks.Utils.Format | ||
@model SocialProfilesFactModel | ||
|
||
@Model.ShortTitle: | ||
<ul> | ||
@foreach (var item in Model.Values) | ||
{ | ||
<li>@item.Type.GetEnumDescription(): @item.Value</li> | ||
} | ||
</ul> |
36 changes: 36 additions & 0 deletions
36
src/Bonsai/Areas/Admin/Views/Pages/Facts/SocialProfilesFactModel.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@using Bonsai.Code.DomainModel.Facts.Models | ||
@using Impworks.Utils.Format | ||
<script type="text/x-template" data-kind="fact-template" id="SocialProfilesFactModel"> | ||
<div class="fact-wrapper"> | ||
<h6> | ||
{{def.title}} | ||
<button type="button" class="btn btn-outline-secondary btn-sm" v-on:click="add({})" title="Указать ссылку"> | ||
<i class="fa fa-plus"></i> | ||
</button> | ||
</h6> | ||
<div v-if="!emptyList()" class="fact-list"> | ||
<div class="row" v-for="row in getList()"> | ||
<div class="col-sm-8 form form-fact fact-list-item"> | ||
<div class="form-row"> | ||
<div class="form-group col-sm-4"> | ||
<label>Тип</label> | ||
<select v-model="row.Type" class="form-control form-control-sm mr-2"> | ||
@foreach (var prof in EnumHelper.GetEnumDescriptions<SocialProfileType>()) | ||
{ | ||
<option value="@prof.Key">@prof.Value</option> | ||
} | ||
</select> | ||
</div> | ||
<div class="form-group col-sm-8"> | ||
<button type="button" class="btn btn-outline-danger btn-sm btn-remove-fact" v-on:click="remove(row)" title="Удалить ссылку"> | ||
<i class="fa fa-remove"></i> | ||
</button> | ||
<label>Ссылка</label> | ||
<input type="text" v-model="row.Value" class="form-control form-control-sm mr-2" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Bonsai/Areas/Front/Views/Page/Facts/SocialProfilesFactModel.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@using Bonsai.Code.DomainModel.Facts.Models | ||
@using Impworks.Utils.Format | ||
@model SocialProfilesFactModel | ||
|
||
<tr class="fact"> | ||
<th class="fact-title">@Model.ShortTitle</th> | ||
</tr> | ||
<tr class="fact"> | ||
<td class="fact-value big-icons"> | ||
@foreach (var item in Model.Values) | ||
{ | ||
<a class="big-icon" href="@item.Value" target="_blank" title="@item.Type.GetEnumDescription()"> | ||
<span class="fa @(GetIcon(item.Type))"></span> | ||
</a> | ||
} | ||
</td> | ||
</tr> | ||
|
||
@functions { | ||
string GetIcon(SocialProfileType type) | ||
{ | ||
return type switch | ||
{ | ||
SocialProfileType.Facebook => "fa-facebook-square", | ||
SocialProfileType.Twitter => "fa-twitter-square", | ||
SocialProfileType.Github => "fa-github", | ||
SocialProfileType.Youtube => "fa-youtube-play", | ||
SocialProfileType.Telegram => "fa-telegram", | ||
SocialProfileType.Odnoklassniki => "fa-odnoklassniki-square", | ||
SocialProfileType.Vkontakte => "fa-vk", | ||
_ => null | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/Bonsai/Code/DomainModel/Facts/Models/SocialProfilesFactModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Bonsai.Code.DomainModel.Facts.Models | ||
{ | ||
/// <summary> | ||
/// Template for specifying known social profile links. | ||
/// </summary> | ||
public class SocialProfilesFactModel: FactListModelBase<SocialProfileFactItem> | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Single social profile link. | ||
/// </summary> | ||
public class SocialProfileFactItem | ||
{ | ||
/// <summary> | ||
/// Type of the profile. | ||
/// </summary> | ||
public SocialProfileType Type { get; set; } | ||
|
||
/// <summary> | ||
/// Link to the profile. | ||
/// </summary> | ||
public string Value { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Known social profile links (to display icons properly). | ||
/// </summary> | ||
public enum SocialProfileType | ||
{ | ||
[Description("Facebook")] | ||
Facebook, | ||
|
||
[Description("Twitter")] | ||
Twitter, | ||
|
||
[Description("Одноклассники")] | ||
Odnoklassniki, | ||
|
||
[Description("Вконтакте")] | ||
Vkontakte, | ||
|
||
[Description("Telegram")] | ||
Telegram, | ||
|
||
[Description("Youtube")] | ||
Youtube, | ||
|
||
[Description("Github")] | ||
Github, | ||
} | ||
} |