diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 67b50dddcb..62061f90d4 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -350,6 +350,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", + "PostNotificationOptions", + { contentId: id, notifyOptions: options })), + 'Failed to set notify settings for content id ' + id); + }, + /** * @ngdoc method * @name umbraco.resources.contentResource#getByIds diff --git a/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less b/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less index 2156f75d00..73f059b4ee 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less @@ -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; -} \ No newline at end of file +} diff --git a/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less b/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less index 54116e9093..c041f3f4ea 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less @@ -20,6 +20,7 @@ .umb-permission__content { display: flex; flex-direction: column; + justify-content: center; flex: 1 1 auto; cursor: pointer; } @@ -27,4 +28,4 @@ .umb-permission__description { font-size: 13px; color: @gray-5; -} \ No newline at end of file +} diff --git a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html index e850bf22b8..ba9257bac7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html @@ -1,4 +1,4 @@ - + diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.notify.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.notify.controller.js new file mode 100644 index 0000000000..4ab0c89beb --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.notify.controller.js @@ -0,0 +1,49 @@ +(function () { + function CreateNotifyController( + $scope, + contentResource, + navigationService, + 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 selectedString = []; + angular.forEach(notifyOptions, + function(option) { + if (option.checked === true && option.notifyCode) { + selectedString.push(option.notifyCode); + } + console.log('selectedString', selectedString); + + contentResource.setNotifySettingsById($scope.currentNode.id, selectedString).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); +}()); diff --git a/src/Umbraco.Web.UI.Client/src/views/content/notify.html b/src/Umbraco.Web.UI.Client/src/views/content/notify.html new file mode 100644 index 0000000000..ec9b3d2b0d --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/content/notify.html @@ -0,0 +1,44 @@ +
+ +
+
+
+
+
{{vm.saveError.errorMsg}}
+
{{vm.saveError.data.message}}
+
+
+
+
+ {{currentNode.name}} +
+
+
+
+
Set your notification for {{ currentNode.name }}
+ + + + +
+
+ +
+
+
diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml index 4620ff3314..dce1986868 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml @@ -424,6 +424,7 @@ Navnet '%0%' eksisterer allerede. ]]> + Ordbog Indtast dit brugernavn diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index e29d3c45eb..cf810fbd24 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -2038,9 +2038,9 @@ To manage your website, simply open the Umbraco back office and start adding con Validation - Validate as email + Validate as an email address Validate as a number - Validate as a Url + Validate as a URL ...or enter a custom validation Field is mandatory Enter a regular expression diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index a195a1d23a..e32300e86a 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -2052,9 +2052,9 @@ To manage your website, simply open the Umbraco back office and start adding con Validation - Validate as email + Validate as an email address Validate as a number - Validate as a Url + Validate as a URL ...or enter a custom validation Field is mandatory Enter a regular expression @@ -2222,4 +2222,8 @@ To manage your website, simply open the Umbraco back office and start adding con There is no 'restore' relation found for this node. Use the Move menu item to move it manually. The item you want to restore it under ('%0%') is in the recycle bin. Use the Move menu item to move the item manually. + + Select your notifications for + Notification settings saved for + diff --git a/src/Umbraco.Web.UI/Umbraco/dialogs/notifications.aspx b/src/Umbraco.Web.UI/Umbraco/dialogs/notifications.aspx deleted file mode 100644 index d1a93cc64e..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/dialogs/notifications.aspx +++ /dev/null @@ -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.Web._Legacy.Controls" Assembly="Umbraco.Web" %> - - - -
- - - - - -
- -
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json b/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json index e6c42930a8..dbd6b8d4f5 100644 --- a/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json +++ b/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json @@ -54,7 +54,7 @@ { "element": "#applications [data-element='section-user']", "title": "User profile", - "content": "Click on your user avatar to open the user profile dialog.", + "content": "Now click on your user avatar to open the user profile dialog.", "event": "click", "backdropOpacity": 0.6 }, diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 609a2694e0..fde16a34f3 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -25,6 +25,7 @@ using Umbraco.Core.Persistence.Querying; using Umbraco.Web.PublishedCache; using Umbraco.Core.Events; using Umbraco.Core.Models.Validation; +using Umbraco.Web.Composing; using Umbraco.Web.Models; using Umbraco.Web.WebServices; using Umbraco.Web._Legacy.Actions; @@ -32,6 +33,7 @@ using Constants = Umbraco.Core.Constants; using ContentVariation = Umbraco.Core.Models.ContentVariation; using Language = Umbraco.Web.Models.ContentEditing.Language; + namespace Umbraco.Web.Editors { /// @@ -1473,5 +1475,40 @@ namespace Umbraco.Web.Editors return display; } + + [EnsureUserPermissionForContent("contentId", 'R')] + public List GetNotificationOptions(int contentId) + { + var notifications = new List(); + 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 userNotifications = Services.NotificationService.GetUserNotifications(Security.CurrentUser, content.Path).ToList(); + + foreach (var a in Current.Actions.Where(x => x.ShowInNotifier)) + { + var n = new NotifySetting + { + Name = Services.TextService.Localize("actions", a.Alias), + Checked = userNotifications.FirstOrDefault(x=> x.Action == a.Letter.ToString()) != null, + NotifyCode = a.Letter.ToString() + }; + notifications.Add(n); + } + + return notifications; + } + + public void PostNotificationOptions(int contentId, [FromUri] 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)); + + Services.NotificationService.SetNotifications(Security.CurrentUser, content, notifyOptions); + } + } } diff --git a/src/Umbraco.Web/Models/ContentEditing/NotifySetting.cs b/src/Umbraco.Web/Models/ContentEditing/NotifySetting.cs new file mode 100644 index 0000000000..bd81b4a55b --- /dev/null +++ b/src/Umbraco.Web/Models/ContentEditing/NotifySetting.cs @@ -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; } + /// + /// The letter from the IAction + /// + [DataMember(Name = "notifyCode")] + public string NotifyCode { get; set; } + public object Clone() + { + return this.MemberwiseClone(); + } + } +} diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index e80867aadf..3581105445 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -235,8 +235,8 @@ namespace Umbraco.Web.Trees AddActionNode(item, menu); AddActionNode(item, menu, convert: true); AddActionNode(item, menu, true, true); - - AddActionNode(item, menu, true, true); + + AddActionNode(item, menu, true); AddActionNode(item, menu, convert: true); AddActionNode(item, menu, true); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index ee54aca612..cedb362aa1 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -223,6 +223,7 @@ + @@ -1287,13 +1288,6 @@ importDocumenttype.aspx ASPXCodeBehind - - notifications.aspx - ASPXCodeBehind - - - notifications.aspx - rollBack.aspx @@ -1445,9 +1439,6 @@ ASPXCodeBehind - - ASPXCodeBehind - ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx deleted file mode 100644 index 77c4841d7d..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx +++ /dev/null @@ -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.Web._Legacy.Controls" %> - - - -
- - - - - -
- -
\ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx.cs deleted file mode 100644 index ef3cc5f63b..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx.cs +++ /dev/null @@ -1,111 +0,0 @@ -using Umbraco.Core.Services; -using System; -using System.Collections; -using System.Globalization; -using System.Linq; -using System.Web.UI.WebControls; -using Umbraco.Core; -using Umbraco.Core.Models.Entities; -using Umbraco.Web; -using Umbraco.Web.Composing; -using Umbraco.Web.UI.Pages; -using Umbraco.Web._Legacy.Actions; - -namespace umbraco.dialogs -{ - /// - /// Summary description for cruds. - /// - public partial class notifications : UmbracoEnsuredPage - { - private ArrayList actions = new ArrayList(); - private IUmbracoEntity node; - - public notifications() - { - CurrentApp = Constants.Applications.Content.ToString(); - - } - - protected void Page_Load(object sender, EventArgs e) - { - Button1.Text = Services.TextService.Localize("update"); - pane_form.Text = Services.TextService.Localize("notifications/editNotifications", new[] { Server.HtmlEncode(node.Name) }); - } - - #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 = Services.EntityService.Get(int.Parse(Request.GetItemAsString("id"))); - - var actionList = Current.Actions; - - foreach (var a in actionList) - { - if (a.ShowInNotifier) - { - - CheckBox c = new CheckBox(); - c.ID = a.Letter.ToString(CultureInfo.InvariantCulture); - - var notifications = Services.NotificationService.GetUserNotifications(Security.CurrentUser, node.Path); - if (notifications.Any(x => x.Action == a.Letter.ToString())) - c.Checked = true; - - var pp = new Umbraco.Web._Legacy.Controls.PropertyPanel(); - pp.CssClass = "inline"; - pp.Text = Services.TextService.Localize("actions", a.Alias); - pp.Controls.Add(c); - - pane_form.Controls.Add(pp); - - actions.Add(c); - - } - } - - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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; - } - - Current.Services.NotificationService.SetNotifications(Security.CurrentUser, node, notifications.ToCharArray().Select(x => x.ToString()).ToArray()); - - var feedback = new Umbraco.Web._Legacy.Controls.Feedback(); - feedback.Text = Services.TextService.Localize("notifications") + " " + Services.TextService.Localize("ok") + "

" + Services.TextService.Localize("closeThisWindow") + ""; - feedback.type = Umbraco.Web._Legacy.Controls.Feedback.feedbacktype.success; - - pane_form.Controls.Clear(); - pane_form.Controls.Add(feedback); - - //pane_form.Visible = false; - pl_buttons.Visible = false; - } - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx.designer.cs deleted file mode 100644 index 861f6bbbfb..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/notifications.aspx.designer.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.dialogs { - - - public partial class notifications { - - ///

- /// pane_form control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.Pane pane_form; - - /// - /// pl_buttons control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlGenericControl pl_buttons; - - /// - /// Button1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button Button1; - } -}