From dc9b4b7dee2e0b69994094d879c7f18eea4c8859 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 14 Nov 2019 14:38:25 +0800 Subject: [PATCH 1/7] =?UTF-8?q?refactor:=20=E5=90=8C=E6=AD=A5=20lgbSelect?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/longbow-select/longbow-select.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js index 6001c350..1088d9eb 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js @@ -114,7 +114,7 @@ // save attributes var attrs = []; - ["id", "data-default-val"].forEach(function (v, index) { + ["id", "name", "data-default-val"].forEach(function (v, index) { var value = that.$element.attr(v); if (value !== undefined) attrs.push({ name: v, value: value }); }); @@ -139,12 +139,15 @@ this.$input.removeAttr('disabled'); }; - _proto.reset = function (value) { + _proto.reset = function (value, init) { var that = this; // keep old value var oldValue = this.$input.attr('value'); + // default select value + if (init == undefined) init = true; + // warning: must use attr('value') method instead of val(). otherwise the others input html element will filled by first element value. // see https://gitee.com/LongbowEnterprise/longbow-select/issues/IZ3BR?from=project-issue this.$input.attr('value', '').removeClass('is-valid is-invalid'); @@ -153,10 +156,12 @@ $.each(value, function (index) { var $item = $('' + this.text + ''); that.$menus.append($item); - if (this.selected === true || this.value === oldValue || index === 0 || this.value === that.$element.attr('data-default-val')) { - that.$input.attr('value', this.text); - that.$element.val(this.value).attr('data-text', this.text); - $activeItem = $item; + if (init) { + if (this.selected === true || this.value === oldValue || index === 0 || this.value === that.$element.attr('data-default-val')) { + that.$input.attr('value', this.text); + that.$element.val(this.value).attr('data-text', this.text); + $activeItem = $item; + } } }); if ($activeItem !== null) $activeItem.addClass('active'); From 3eaa058585b83a39366fcf95156807e63e132e66 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 14 Nov 2019 15:17:45 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20lgbSelect=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=20disabled=20=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/lib/longbow-select/longbow-select.css | 4 ++++ .../wwwroot/lib/longbow-select/longbow-select.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.css b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.css index 6ea594a0..ffdb1968 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.css +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.css @@ -50,6 +50,10 @@ cursor: not-allowed; } +.form-select.is-disabled .form-select-append { + color: #c0c4cc; +} + .form-select-input { color: #606266; outline: none; diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js index 1088d9eb..84205ba0 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js @@ -119,6 +119,12 @@ if (value !== undefined) attrs.push({ name: v, value: value }); }); + var disabled = this.$element.prop('disabled'); + // set disabled property + if (disabled) { + this.disabled(); + } + // replace element select -> input hidden this.$element.remove(); this.$element = $('').val(that.val()).insertBefore(this.$input); From 926e2542648900a7f9670dfe5725d481de7f8056 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 14 Nov 2019 15:18:49 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix(#I14DVA):=20=E8=8F=9C=E5=8D=95=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E6=A0=B9=E6=8D=AE=E6=89=80=E5=B1=9E=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Link https://gitee.com/LongbowEnterprise/dashboard/issues?id=I14DVA --- .../Bootstrap.Admin/Views/Admin/Menus.cshtml | 24 +++++++++---------- src/admin/Bootstrap.Admin/wwwroot/js/menus.js | 7 ++++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml b/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml index 9c1903f1..6ffc7bd5 100644 --- a/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml @@ -147,10 +147,11 @@
- - + + +
@@ -162,14 +163,6 @@
-
- - -
+
+ + +
diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js index 0915663f..7579a1d5 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js @@ -333,4 +333,11 @@ $(function () { }); } }); + + // 所属应用更新是联动菜单类别 + var $app = $('#app').on('changed.lgbSelect', function (e) { + var defaultVal = $app.attr('data-default-val'); + var val = defaultVal === $app.val() ? '0' : '1'; + $category.lgbSelect('val', val); + }) }); \ No newline at end of file From 9f832c365e886788bffa758d7f0b996b2576a3cd Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 14 Nov 2019 16:24:26 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix(#I13MQ4):=20=E4=BF=9D=E5=AD=98=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=97=B6=E5=88=B7=E6=96=B0=E4=BE=A7=E8=BE=B9=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #I13MQ4 #Issue link https://gitee.com/LongbowEnterprise/dashboard/issues?id=I13MQ4 --- .../Bootstrap.Admin/wwwroot/lib/longbow/longbow.dataentity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.dataentity.js b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.dataentity.js index f8d2193e..9ecf73a5 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.dataentity.js +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.dataentity.js @@ -183,7 +183,7 @@ callback: function (result) { if (result) { $(options.bootstrapTable).bootstrapTable('refresh'); - handlerCallback.call(that, null, element, { oper: 'save', success: result, data: options.data }); + handlerCallback.call(that, null, element, { oper: 'save', success: result, data: [options.data] }); } } }); From 0abd9aa9eb29eb31a3d6c50a217035021da95862 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 14 Nov 2019 16:26:59 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix(#I13MQS):=20=E4=BF=9D=E5=AD=98=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=97=B6=E6=A3=80=E6=9F=A5=E8=8F=9C=E5=8D=95=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #I13MQS 增加客户端检查 menuChild rule #Issue link https://gitee.com/LongbowEnterprise/dashboard/issues?id=I13MQS --- .../Controllers/Api/CategoryController.cs | 10 ++++++++++ .../Bootstrap.Admin/Views/Admin/Menus.cshtml | 2 +- src/admin/Bootstrap.Admin/wwwroot/js/menus.js | 18 ++++++++++++++++++ .../lib/longbow-select/longbow-select.js | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs index 53944ae3..809d295f 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs @@ -44,5 +44,15 @@ namespace Bootstrap.Admin.Controllers.Api { return MenuHelper.RetrieveMenus(User.Identity.Name).Where(m => m.Menus.Count() > 0).OrderBy(m => m.Name).Select(m => m.Name); } + + /// + /// 通过指定菜单检查子菜单是否有子菜单 + /// + /// + [HttpGet("{id}")] + public bool ValidateMenuBySubMenu(string id) + { + return !MenuHelper.RetrieveAllMenus(User.Identity.Name).Where(m => m.ParentId == id).Any(); + } } } diff --git a/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml b/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml index 6ffc7bd5..2a756e05 100644 --- a/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Admin/Menus.cshtml @@ -148,7 +148,7 @@
- diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js index 7579a1d5..626c9c35 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js @@ -340,4 +340,22 @@ $(function () { var val = defaultVal === $app.val() ? '0' : '1'; $category.lgbSelect('val', val); }) + + if ($.isFunction($.validator)) { + $.validator.addMethod("menuChild", function (value, element) { + var id = $("#menuID").val(); + var check = id === "" || value === "菜单"; + if (!check) { + $.get({ + url: $.formatUrl('api/Category/ValidateMenuBySubMenu/' + id), + async: false, + cache: false, + success: function (result) { + check = result + } + }); + } + return check; + }, "拥有子菜单时菜单类型不可更改为资源或者按钮"); + } }); \ No newline at end of file diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js index 84205ba0..4ae2b817 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js @@ -114,7 +114,7 @@ // save attributes var attrs = []; - ["id", "name", "data-default-val"].forEach(function (v, index) { + ["id", "name", "class", "data-valid", "data-default-val"].forEach(function (v, index) { var value = that.$element.attr(v); if (value !== undefined) attrs.push({ name: v, value: value }); }); From cd1f242b2b91a2dca90cc6613e41311cae48f0a8 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 14 Nov 2019 18:41:48 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix(#IS7XT):=20=E7=88=B6=E7=BA=A7=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E7=A6=81=E6=AD=A2=E9=80=89=E6=8B=A9=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=88=96=E8=80=85=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #IS7XT #Issue link https://gitee.com/LongbowEnterprise/dashboard/issues?id=IS7XT --- .../Controllers/Api/CategoryController.cs | 10 ++++++++ .../wwwroot/js/common-scripts.js | 8 +++--- src/admin/Bootstrap.Admin/wwwroot/js/menus.js | 25 +++++++++---------- .../wwwroot/lib/longbow/longbow.common.js | 13 ++++++++++ 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs index 809d295f..1158b60f 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs @@ -54,5 +54,15 @@ namespace Bootstrap.Admin.Controllers.Api { return !MenuHelper.RetrieveAllMenus(User.Identity.Name).Where(m => m.ParentId == id).Any(); } + + /// + /// 通过指定菜单检查父级菜单是否为菜单类型 资源与按钮返回 false + /// + /// + [HttpGet("{id}")] + public bool ValidateParentMenuById(string id) + { + return MenuHelper.RetrieveAllMenus(User.Identity.Name).FirstOrDefault(m => m.Id == id)?.IsResource == 0; + } } } diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js b/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js index de1bc3e9..df4d0c45 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js @@ -131,10 +131,10 @@ var html = ""; $.each(menus, function (index, menu) { if (menu.Menus.length === 0) { - html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu)); + html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu), menu.IsResource); } else { - html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu)); + html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu), menu.IsResource); } }); return html; @@ -144,10 +144,10 @@ var html = ""; $.each(menus, function (index, menu) { if (menu.Menus.length === 0) { - html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu)); + html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu), menu.IsResource); } else { - html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu)); + html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu), menu.IsResource); } }); return html; diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js index 626c9c35..da08d963 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js @@ -217,6 +217,7 @@ $(function () { $btnSubmitMenu.data('type', 'parent'); $nestMenuInput.find('label:last').find('input').show(); $nestMenu.find('li.dd-item').hide().remove('[data-id="0"]'); + $nestMenu.find('li[data-resource!="0"]').find(':radio').prop('disabled', true) $nestMenu.find('li[data-category="' + $category.val() + '"]').show(); showDialog(); }); @@ -240,8 +241,16 @@ $(function () { var type = $(this).data('type'); switch (type) { case "parent": - $parentMenuID.val($('.dd3-content :radio:checked').val()); - $parentMenuName.val($('.dd3-content :radio:checked').next('span').text()); + // 父级菜单不可以是资源或者按钮类型 + var pId = $('.dd3-content :radio:checked').val(); + var check = $.remoteValidate('api/Category/ValidateParentMenuById/' + pId); + if (check) { + $parentMenuID.val(pId); + $parentMenuName.val($('.dd3-content :radio:checked').next('span').text()); + } + else { + return false; + } break; case "order": var data = $nestMenu.find('li:visible'); @@ -344,17 +353,7 @@ $(function () { if ($.isFunction($.validator)) { $.validator.addMethod("menuChild", function (value, element) { var id = $("#menuID").val(); - var check = id === "" || value === "菜单"; - if (!check) { - $.get({ - url: $.formatUrl('api/Category/ValidateMenuBySubMenu/' + id), - async: false, - cache: false, - success: function (result) { - check = result - } - }); - } + var check = id === "" || value === "菜单" || $.remoteValidate('api/Category/ValidateMenuBySubMenu/' + id); return check; }, "拥有子菜单时菜单类型不可更改为资源或者按钮"); } diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js index 4c422fbe..274e63fa 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js @@ -125,6 +125,19 @@ document.webkitIsFullScreen || window.fullscreen || false; }, + remoteValidate: function (url, method) { + if (method === undefined) method = 'get'; + var check = false; + jQuery[method]({ + url: $.formatUrl(url), + async: false, + cache: false, + success: function (result) { + check = result + } + }); + return check; + }, bc: function (options) { options = $.extend({ id: "", From 9cd4c966a3c981ad2023899514099f6ff6867884 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 14 Nov 2019 19:08:45 +0800 Subject: [PATCH 7/7] =?UTF-8?q?refactor:=20=E7=88=B6=E7=BA=A7=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=88=97=E8=A1=A8=E4=B8=AD=E8=B5=84=E6=BA=90=E6=88=96?= =?UTF-8?q?=E8=80=85=E6=8C=89=E9=92=AE=E8=8F=9C=E5=8D=95=E9=A1=B9=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B5=85=E7=81=B0=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/Bootstrap.Admin/wwwroot/css/site.css | 4 ++++ src/admin/Bootstrap.Admin/wwwroot/js/menus.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/admin/Bootstrap.Admin/wwwroot/css/site.css b/src/admin/Bootstrap.Admin/wwwroot/css/site.css index ad262739..15f1c2cc 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/css/site.css +++ b/src/admin/Bootstrap.Admin/wwwroot/css/site.css @@ -353,6 +353,10 @@ body.trans-mute * { right: 45px; } +li.is-disabled .dd3-content { + color: #c0c4cc; +} + @media (max-width: 480px) { .dd3-content .menuType { display: none; diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js index da08d963..070266d2 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js @@ -217,7 +217,7 @@ $(function () { $btnSubmitMenu.data('type', 'parent'); $nestMenuInput.find('label:last').find('input').show(); $nestMenu.find('li.dd-item').hide().remove('[data-id="0"]'); - $nestMenu.find('li[data-resource!="0"]').find(':radio').prop('disabled', true) + $nestMenu.find('li[data-resource!="0"]').addClass('is-disabled').find(':radio').prop('disabled', true) $nestMenu.find('li[data-category="' + $category.val() + '"]').show(); showDialog(); });