Implemented deletion and styles

pull/4776/head
Halil İbrahim Kalkan 5 years ago
parent abf06c1727
commit 8210eb27aa

@ -5,7 +5,7 @@
@foreach (var reaction in Model.Reactions)
{
<span class="mr-2">
<img src="@reaction.Icon" width="16" height="16" data-name="@reaction.Name" class="cms-reaction-icon @(reaction.IsSelectedByCurrentUser ? "cms-reaction-icon-highlighted" : "")"/>
<img src="@reaction.Icon" width="16" height="16" data-name="@reaction.Name" class="cms-reaction-icon @(reaction.IsSelectedByCurrentUser ? "cms-reaction-icon-selected" : "")"/>
</span>
}
</div>
@ -14,7 +14,7 @@
@foreach (var reaction in Model.Reactions.Where(r => r.Count > 0))
{
<span class="mr-2">
<img src="@reaction.Icon" width="20" height="20" data-name="@reaction.Name" class="cms-reaction-icon @(reaction.IsSelectedByCurrentUser ? "cms-reaction-icon-highlighted" : "")"/>
<img src="@reaction.Icon" width="20" height="20" data-name="@reaction.Name" class="cms-reaction-icon @(reaction.IsSelectedByCurrentUser ? "cms-reaction-icon-selected" : "")"/>
<span> @reaction.Count</span>
</span>
}

@ -5,9 +5,6 @@ using Volo.Abp.Modularity;
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.ReactionSelection
{
[DependsOn(
typeof(BootstrapScriptContributor)
)]
public class ReactionSelectionScriptBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)

@ -0,0 +1,13 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.ReactionSelection
{
public class ReactionSelectionStyleBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/ReactionSelection/default.css");
}
}
}

@ -9,7 +9,8 @@ using Volo.CmsKit.Reactions;
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.ReactionSelection
{
[Widget(
ScriptTypes = new[] {typeof(ReactionSelectionScriptBundleContributor)}
ScriptTypes = new[] {typeof(ReactionSelectionScriptBundleContributor)},
StyleTypes = new[] {typeof(ReactionSelectionStyleBundleContributor)}
)]
public class ReactionSelectionViewComponent : AbpViewComponent
{

@ -0,0 +1,8 @@
.cms-reaction-icon
{
cursor: pointer;
}
.cms-reaction-icon-selected
{
border: 1px solid gray;
}

@ -1,23 +1,25 @@
(function () {
$(document).ready(function () {
function initReactionSelection(){
var $this = $(this);
var $availableReactions = $this.find('.cms-reaction-selection-available-reactions');
function initReactionSelection() {
var $wrapper = $(this);
var $availableReactions = $wrapper.find('.cms-reaction-selection-available-reactions');
$availableReactions.find('.cms-reaction-icon').each(function(){
$wrapper.find('.cms-reaction-icon').each(function () {
var $icon = $(this);
$icon.click(function(){
volo.cmsKit.reactions.reactionPublic.create({
entityType: $this.attr('data-entity-type'),
entityId: $this.attr('data-entity-id'),
$icon.click(function () {
var methodName = $icon.hasClass('cms-reaction-icon-selected') ? 'delete' : 'create';
volo.cmsKit.reactions.reactionPublic[methodName]({
entityType: $wrapper.attr('data-entity-type'),
entityId: $wrapper.attr('data-entity-id'),
reactionName: $icon.attr('data-name')
}).then(function () {
location.reload(); //TODO: JUST TESTING !!!!!!!!
});
});
});
}
$('.cms-reaction-selection').each(initReactionSelection);
});
})();

Loading…
Cancel
Save