Fixes label ui issue on template editor ui.

Updated notification settings ui to use angular instead of web forms.
This commit is contained in:
Mike
2018-08-06 19:52:29 +01:00
parent 5e9f73b114
commit 2b6c6b3022
18 changed files with 205 additions and 222 deletions

View File

@@ -337,6 +337,29 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
'Failed to retrieve data for content id ' + id);
},
getNotifySettingsById: function (id) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"contentApiBaseUrl",
"GetNotificationOptions",
[{ contentId: id }])),
'Failed to retrieve data for content id ' + id);
},
setNotifySettingsById: function (id, options) {
if (!id) {
throw "contentId cannot be null";
}
return umbRequestHelper.resourcePromise(
$http.post(
umbRequestHelper.getApiUrl(
"contentApiBaseUrl",
"SetNotificationOptions",
{ contentId: id, notifyOptions: options })),
'Failed to set notify settings for content id ' + id);
},
/**
* @ngdoc method
* @name umbraco.resources.contentResource#getByIds

View File

@@ -1,10 +1,20 @@
.umb-toggle {
display: flex;
align-items: center;
display: flex;
align-items: center;
background: none;
border: none;
padding: 0;
&:focus {
outline: 0;
}
}
.umb-toggle__handler {
display: inline-block;
position: absolute;
top: 0;
left: 0;
display: block;
width: 24px;
height: 24px;
background-color: @white;
@@ -62,4 +72,4 @@
.umb-toggle__icon--right {
right: 7px;
color: @gray-5;
}
}

View File

@@ -16,6 +16,7 @@
.umb-permission__content {
display: flex;
flex-direction: column;
justify-content: center;
flex: 1 1 auto;
cursor: pointer;
}
@@ -23,4 +24,4 @@
.umb-permission__description {
font-size: 13px;
color: @gray-5;
}
}

View File

@@ -7,9 +7,6 @@
<div class="control-group umb-control-group">
<div class="umb-el-wrap">
<label class="control-label" for="dataTypeName">
<localize key="name"></localize>
</label>
<div class="controls">
<input type="text" ng-model="model.dataType.name" class="umb-editor" umb-auto-focus focus-on-filled="true" required />
</div>

View File

@@ -66,10 +66,8 @@
<div class="control-group umb-control-group">
<div class="umb-el-wrap">
<div class="controls">
<label class="control-label" >
<label>
<localize key="templateEditor_recursive">Recursive</localize>
</label>
<label for="recursive">
<input id="recursive" type="checkbox" name="recursive" ng-model="vm.recursive">
<localize key="templateEditor_recursiveDescr">Yes, make it recursive</localize>
</label>
@@ -159,13 +157,11 @@
<div class="control-group umb-control-group">
<div class="umb-el-wrap">
<div class="controls">
<div>
<label class="control-label" for="linebreaks">
<label>
<span class="control-label">
<localize key="templateEditor_convertLineBreaks">Convert line breaks</localize>
<small><localize key="templateEditor_convertLineBreaksHelp">Replaces line breaks with break html tag</localize></small>
</label>
</div>
<label for="linebreaks">
</span>
<input type="checkbox" id="linebreaks" name="linebreaks" ng-model="vm.convertLinebreaks">
<localize key="templateEditor_convertLineBreaksDescription">Yes, convert line breaks</localize>
</label>

View File

@@ -1,4 +1,4 @@
<a href="" ng-click="click()" class="umb-toggle dib" ng-class="{'umb-toggle--checked': checked}">
<button ng-click="click()" class="umb-toggle dib" ng-class="{'umb-toggle--checked': checked}">
<span ng-if="!labelPosition && showLabels === 'true' || labelPosition === 'left' && showLabels === 'true'">
<span ng-if="!checked" class="umb-toggle__label umb-toggle__label--left">{{ displayLabelOff }}</span>
@@ -16,4 +16,4 @@
<span ng-if="checked" class="umb-toggle__label umb-toggle__label--right">{{ displayLabelOn }}</span>
</span>
</a>
</button>

View File

@@ -0,0 +1,49 @@
(function () {
function CreateNotifyController(
$scope,
contentResource,
notificationsService,
navigationService,
localizationService,
angularHelper) {
var vm = this;
var currentForm;
vm.notifyOptions = [];
vm.save = save;
vm.cancel = cancel;
vm.message = {
name: $scope.currentNode.name
};;
function onInit() {
vm.loading = true;
contentResource.getNotifySettingsById($scope.currentNode.id).then(function (options) {
currentForm = angularHelper.getCurrentForm($scope);
vm.loading = false;
vm.notifyOptions = options;
});
}
function cancel() {
navigationService.hideMenu();
};
function save(notifyOptions) {
vm.saveState = "busy";
vm.saveError = false;
vm.saveSuccces = false;
var selectedSting = "";
angular.forEach(notifyOptions, function (option) {
if (option.checked === true && option.notifyCode) {
selectedSting += option.notifyCode;
}
})
contentResource.setNotifySettingsById($scope.currentNode.id, selectedSting).then(function () {
vm.saveState = "success";
vm.saveSuccces = true;
}, function (error) {
vm.saveState = "error";
vm.saveError = error;
});
}
onInit();
}
angular.module("umbraco").controller("Umbraco.Editors.Content.CreateNotifyController", CreateNotifyController);
}());

View File

@@ -0,0 +1,44 @@
<div ng-controller="Umbraco.Editors.Content.CreateNotifyController as vm">
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
<div class="umb-pane" ng-show="!vm.loading">
<form name="notifyForm"
novalidate
val-form-manager>
<div ng-show="vm.saveError" ng-cloak>
<div class="alert alert-error">
<div><strong>{{vm.saveError.errorMsg}}</strong></div>
<div>{{vm.saveError.data.message}}</div>
</div>
</div>
<div ng-show="vm.saveSuccces" ng-cloak>
<div class="alert alert-success">
<localize key="notify_notificationsSavedFor"></localize><strong> {{currentNode.name}}</strong>
</div>
</div>
<div ng-cloak>
<div class="block-form" ng-show="!vm.loading">
<h5><localize key="notify_notifySet">Set your notification for</localize> {{ currentNode.name }}</h5>
<umb-control-group>
<umb-permission ng-repeat="option in vm.notifyOptions"
name="option.name"
description="option.description"
selected="option.checked">
</umb-permission>
</umb-control-group>
</div>
</div>
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
<umb-button label-key="general_cancel"
action="vm.cancel()"
type="button"
button-style="link">
</umb-button>
<umb-button label-key="buttons_save"
type="button"
action="vm.save(vm.notifyOptions)"
button-style="success">
</umb-button>
</div>
</form>
</div>
</div>

View File

@@ -49,6 +49,7 @@
<RestorePackages>true</RestorePackages>
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
<UseGlobalApplicationHostFile />
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\</OutputPath>
@@ -760,7 +761,6 @@
<Content Include="Umbraco\Dialogs\create.aspx" />
<Content Include="Umbraco\Dialogs\exportDocumenttype.aspx" />
<Content Include="Umbraco\Dialogs\importDocumenttype.aspx" />
<Content Include="Umbraco\Dialogs\notifications.aspx" />
<Content Include="Umbraco\Dialogs\protectPage.aspx" />
<Content Include="Umbraco\Dialogs\publish.aspx" />
<Content Include="Umbraco\Dialogs\rollBack.aspx" />

View File

@@ -2201,4 +2201,8 @@ To manage your website, simply open the Umbraco back office and start adding con
<key alias="noRestoreRelation">There is no 'restore' relation found for this node. Use the Move menu item to move it manually.</key>
<key alias="restoreUnderRecycled">The item you want to restore it under ('%0%') is in the recycle bin. Use the Move menu item to move the item manually.</key>
</area>
<area alias="notify">
<key alias="notifySet">Select your notifications for</key>
<key alias="notificationsSavedFor">Notification settings saved for </key>
</area>
</language>

View File

@@ -1,18 +0,0 @@
<%@ Page Language="c#" MasterPageFile="../masterpages/umbracoDialog.Master" Codebehind="notifications.aspx.cs" AutoEventWireup="True"
Inherits="umbraco.dialogs.notifications" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<asp:Content ContentPlaceHolderID="body" runat="server">
<div class="umb-dialog-body form-horizontal">
<cc1:Pane ID="pane_form" runat="server">
</cc1:Pane>
</div>
<div runat="server" ID="pl_buttons" class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
<a href="#" class="btn btn-link" onclick="UmbClientMgr.closeModalWindow()"><%=umbraco.ui.Text("general", "cancel")%></a>
<asp:Button ID="Button1" runat="server" CssClass="btn btn-primary" OnClick="Button1_Click"></asp:Button>
</div>
</asp:Content>

View File

@@ -9,7 +9,6 @@ using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
using AutoMapper;
using umbraco.BusinessLogic.Actions;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
@@ -23,10 +22,11 @@ using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Binders;
using Umbraco.Web.WebApi.Filters;
using umbraco.cms.businesslogic.web;
using umbraco.presentation.preview;
using Umbraco.Core.Events;
using Constants = Umbraco.Core.Constants;
using umbraco.cms.businesslogic;
using System.Collections;
using umbraco;
namespace Umbraco.Web.Editors
{
@@ -68,7 +68,7 @@ namespace Umbraco.Web.Editors
{
controllerSettings.Services.Replace(typeof(IHttpActionSelector), new ParameterSwapControllerActionSelector(
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetNiceUrl", "id", typeof(int), typeof(Guid), typeof(Udi)),
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetById", "id", typeof(int), typeof(Guid), typeof(Udi))
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetById", "id", typeof(int), typeof(Guid), typeof(Udi))
));
}
}
@@ -1156,5 +1156,37 @@ namespace Umbraco.Web.Editors
return allowed;
}
[EnsureUserPermissionForContent("contentId", 'R')]
public List<NotifySetting> GetNotificationOptions(int contentId)
{
List<NotifySetting> notifications = new List<NotifySetting>();
if (contentId <= 0) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
var content = Services.ContentService.GetById(contentId);
if (content == null) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
var node = new CMSNode(contentId);
ArrayList actionList = global::umbraco.BusinessLogic.Actions.Action.GetAll();
foreach (global::umbraco.interfaces.IAction a in actionList)
{
if (a.ShowInNotifier)
{
NotifySetting n = new NotifySetting
{
Name = ui.Text("actions", a.Alias),
Checked = (UmbracoUser.GetNotifications(node.Path).IndexOf(a.Letter) > -1),
NotifyCode = a.Letter.ToString()
};
notifications.Add(n);
}
}
return notifications;
}
public void SetNotificationOptions(int contentId, string notifyOptions = "")
{
if (contentId <= 0) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
var content = Services.ContentService.GetById(contentId);
if (content == null) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
var node = new CMSNode(contentId);
global::umbraco.cms.businesslogic.workflow.Notification.UpdateNotifications(UmbracoUser, node, notifyOptions ?? "");
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Runtime.Serialization;
namespace Umbraco.Web.Models.ContentEditing
{
[DataContract(Name = "notifySetting", Namespace = "")]
public class NotifySetting : ICloneable
{
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "checked")]
public bool Checked { get; set; }
/// <summary>
/// The letter from the IAction
/// </summary>
[DataMember(Name = "notifyCode")]
public string NotifyCode { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
}
}

View File

@@ -105,7 +105,7 @@ namespace Umbraco.Web.Trees
}
protected override MenuItemCollection PerformGetMenuForNode(string id, FormDataCollection queryStrings)
{
{
if (id == Constants.System.Root.ToInvariantString())
{
var menu = new MenuItemCollection();
@@ -159,7 +159,7 @@ namespace Umbraco.Web.Trees
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
//if the user has no path access for this node, all they can do is refresh
if (Security.CurrentUser.HasPathAccess(item, Services.EntityService, RecycleBinId) == false)
{
@@ -235,7 +235,7 @@ namespace Umbraco.Web.Trees
menu.Items.Add<ActionRights>(ui.Text("actions", ActionRights.Instance.Alias), true);
menu.Items.Add<ActionProtect>(ui.Text("actions", ActionProtect.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content");
menu.Items.Add<ActionNotify>(ui.Text("actions", ActionNotify.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content");
menu.Items.Add<ActionNotify>(ui.Text("actions", ActionNotify.Instance.Alias), true);
menu.Items.Add<ActionSendToTranslate>(ui.Text("actions", ActionSendToTranslate.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content");
menu.Items.Add<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);

View File

@@ -344,6 +344,7 @@
<Compile Include="Models\BackOfficeTourFilter.cs" />
<Compile Include="Models\ContentEditing\BackOfficePreview.cs" />
<Compile Include="Models\ContentEditing\DocumentTypeCollectionDisplay.cs" />
<Compile Include="Models\ContentEditing\NotifySetting.cs" />
<Compile Include="Models\Mapping\AutoMapperExtensions.cs" />
<Compile Include="Models\Mapping\ContentTreeNodeUrlResolver.cs" />
<Compile Include="Models\Mapping\MemberTreeNodeUrlResolver.cs" />
@@ -1550,13 +1551,6 @@
<DependentUpon>importDocumenttype.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\dialogs\notifications.aspx.cs">
<DependentUpon>notifications.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\dialogs\notifications.aspx.designer.cs">
<DependentUpon>notifications.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco.presentation\umbraco\dialogs\rollBack.aspx.cs">
<DependentUpon>rollBack.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -1885,9 +1879,6 @@
</Content>
<Content Include="umbraco.presentation\umbraco\dialogs\exportDocumenttype.aspx" />
<Content Include="umbraco.presentation\umbraco\dialogs\importDocumenttype.aspx" />
<Content Include="umbraco.presentation\umbraco\dialogs\notifications.aspx">
<SubType>ASPXCodeBehind</SubType>
</Content>
<Content Include="umbraco.presentation\umbraco\dialogs\rollBack.aspx">
<SubType>ASPXCodeBehind</SubType>
</Content>

View File

@@ -1,18 +0,0 @@
<%@ Page Language="c#" MasterPageFile="../masterpages/umbracoDialog.Master" Codebehind="notifications.aspx.cs" AutoEventWireup="True"
Inherits="umbraco.dialogs.notifications" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<asp:Content ContentPlaceHolderID="body" runat="server">
<div class="umb-dialog-body form-horizontal">
<cc1:Pane ID="pane_form" runat="server">
</cc1:Pane>
</div>
<div runat="server" ID="pl_buttons" class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
<a href="#" class="btn btn-link" onclick="UmbClientMgr.closeModalWindow()"><%=umbraco.ui.Text("general", "cancel")%></a>
<asp:Button ID="Button1" runat="server" CssClass="btn btn-primary" OnClick="Button1_Click"></asp:Button>
</div>
</asp:Content>

View File

@@ -1,108 +0,0 @@
using System;
using System.Collections;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using umbraco.BasePages;
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.workflow;
namespace umbraco.dialogs
{
/// <summary>
/// Summary description for cruds.
/// </summary>
public partial class notifications : UmbracoEnsuredPage
{
private ArrayList actions = new ArrayList();
private CMSNode node;
public notifications()
{
CurrentApp = BusinessLogic.DefaultApps.content.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
Button1.Text = ui.Text("update");
pane_form.Text = ui.Text("notifications", "editNotifications", Server.HtmlEncode(node.Text), base.getUser());
}
#region Web Form Designer generated code
protected override void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
node = new cms.businesslogic.CMSNode(int.Parse(helper.Request("id")));
ArrayList actionList = BusinessLogic.Actions.Action.GetAll();
foreach (interfaces.IAction a in actionList)
{
if (a.ShowInNotifier)
{
CheckBox c = new CheckBox();
c.ID = a.Letter.ToString(CultureInfo.InvariantCulture);
if (base.getUser().GetNotifications(node.Path).IndexOf(a.Letter) > -1)
c.Checked = true;
uicontrols.PropertyPanel pp = new umbraco.uicontrols.PropertyPanel();
pp.CssClass = "inline";
pp.Text = ui.Text("actions", a.Alias);
pp.Controls.Add(c);
pane_form.Controls.Add(pp);
actions.Add(c);
}
}
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void Button1_Click(object sender, EventArgs e)
{
string notifications = "";
// First off - load all users
foreach (CheckBox c in actions)
{
// Update the user with the new permission
if (c.Checked)
notifications += c.ID;
}
Notification.UpdateNotifications(base.getUser(), node, notifications);
getUser().resetNotificationCache();
base.getUser().initNotifications();
var feedback = new umbraco.uicontrols.Feedback();
feedback.Text = ui.Text("notifications") + " " + ui.Text("ok") + "</p><p><a href='#' class='btn btn-primary' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
pane_form.Controls.Clear();
pane_form.Controls.Add(feedback);
//pane_form.Visible = false;
pl_buttons.Visible = false;
}
}
}

View File

@@ -1,42 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace umbraco.dialogs {
public partial class notifications {
/// <summary>
/// pane_form control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.Pane pane_form;
/// <summary>
/// pl_buttons control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlGenericControl pl_buttons;
/// <summary>
/// Button1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button Button1;
}
}