Implemented refresh on reaction widget.

pull/4801/head
Halil İbrahim Kalkan 5 years ago
parent 2bc29b2a19
commit 263ee2d21a

@ -1,11 +1,11 @@
using Volo.Abp.AspNetCore.Mvc;
using Volo.CmsKit.Localization;
namespace Volo.CmsKit
namespace Volo.CmsKit.Controllers
{
public abstract class CmsKitPublicController : AbpController
public class CmsKitControllerBase : AbpController
{
protected CmsKitPublicController()
public CmsKitControllerBase()
{
LocalizationResource = typeof(CmsKitResource);
}

@ -0,0 +1,8 @@
using Volo.CmsKit.Controllers;
namespace Volo.CmsKit
{
public abstract class CmsKitPublicControllerBase : CmsKitControllerBase
{
}
}

@ -8,7 +8,7 @@ namespace Volo.CmsKit.Reactions
[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit-public/reactions")]
public class ReactionPublicController : CmsKitPublicController, IReactionPublicAppService
public class ReactionPublicController : CmsKitPublicControllerBase, IReactionPublicAppService
{
protected IReactionPublicAppService ReactionPublicAppService { get; }

@ -0,0 +1,15 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Volo.CmsKit.Web.Controllers
{
//TODO: Consider to move to an area, but also consider to not have the same prefix with API Controllers which can be problem in case of a tiered architecture
public class CmsKitPublicWidgetsController : CmsKitPublicControllerBase
{
public async Task<IActionResult> ReactionSelection(string entityType, string entityId)
{
//TODO: Can we change "CmsReactionSelection" to typeof(ReactionSelectionViewComponent)
return ViewComponent("CmsReactionSelection", new {entityType, entityId});
}
}
}

@ -11,7 +11,8 @@ namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.ReactionSelection
[ViewComponent(Name = "CmsReactionSelection")]
[Widget(
ScriptTypes = new[] {typeof(ReactionSelectionScriptBundleContributor)},
StyleTypes = new[] {typeof(ReactionSelectionStyleBundleContributor)}
StyleTypes = new[] {typeof(ReactionSelectionStyleBundleContributor)},
RefreshUrl = "/CmsKitPublicWidgets/ReactionSelection"
)]
public class ReactionSelectionViewComponent : AbpViewComponent
{

@ -2,27 +2,27 @@
$(document).ready(function () {
abp.widgets.CmsReactionSelection = function ($widget) {
var $reactionSelection = $widget.find('.cms-reaction-selection');
var widgetManager = $widget.data('abp-widget-manager');
function getFilters() {
return {};
}
function refresh(filters) {
location.reload(); //TODO: JUST TESTING !!!!!!!!
return {
entityType: $reactionSelection.attr('data-entity-type'),
entityId: $reactionSelection.attr('data-entity-id')
};
}
function init(filters) {
var $wrapper = $widget.find('.cms-reaction-selection');
$widget.find('.cms-reaction-icon').each(function () {
var $icon = $(this);
$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 () {
refresh();
volo.cmsKit.reactions.reactionPublic[methodName](
$.extend(getFilters(), {
reactionName: $icon.attr('data-name')
})
).then(function () {
widgetManager.refresh($widget);
});
});
});
@ -30,8 +30,7 @@
return {
init: init,
refresh: refresh,
getFilters : getFilters
getFilters: getFilters
};
};

Loading…
Cancel
Save