Browse Source

Implemented refresh on reaction widget.

pull/4801/head
Halil İbrahim Kalkan 6 years ago
parent
commit
263ee2d21a
  1. 6
      modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/CmsKitControllerBase.cs
  2. 8
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/CmsKitPublicControllerBase.cs
  3. 2
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Reactions/ReactionPublicController.cs
  4. 15
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicWidgetsController.cs
  5. 3
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionViewComponent.cs
  6. 27
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/default.js

6
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/CmsKitPublicController.cs → modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/CmsKitControllerBase.cs

@ -1,11 +1,11 @@
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.CmsKit.Localization; 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); LocalizationResource = typeof(CmsKitResource);
} }

8
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/CmsKitPublicControllerBase.cs

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

2
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Reactions/ReactionPublicController.cs

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

15
modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicWidgetsController.cs

@ -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});
}
}
}

3
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionViewComponent.cs

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

27
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/default.js

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

Loading…
Cancel
Save