From 229cd0be8d9318444f10774c9d96e4b5e82623f7 Mon Sep 17 00:00:00 2001 From: luchenqun Date: Thu, 15 Jun 2017 19:00:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B9=A6=E7=AD=BE=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E4=BA=A4=E4=BA=92=E6=96=B9=E5=BC=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/scripts/controllers/edit-controller.js | 49 ++++++++++++++++++- public/views/edit.html | 41 ++++++++++------ 2 files changed, 74 insertions(+), 16 deletions(-) diff --git a/public/scripts/controllers/edit-controller.js b/public/scripts/controllers/edit-controller.js index 38a0973..35ed192 100644 --- a/public/scripts/controllers/edit-controller.js +++ b/public/scripts/controllers/edit-controller.js @@ -1,6 +1,7 @@ -app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $timeout, $document, bookmarkService, pubSubService, dataService) { +app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) { console.log("Hello editCtr"); var maxSelections = 3; + var dialog = null; init(); $scope.$watch('url', function(newUrl, oldUrl, scope) { @@ -139,6 +140,46 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'bookmar } } + $scope.showAddTag = function() { + if ($scope.tags.length < 30) { + console.log('showAddTag..........') + $scope.newTag = ""; + dialog = ngDialog.open({ + template: './views/dialog-add-tag.html', + className: 'ngdialog-theme-default', + scope: $scope + }); + } else { + toastr.error('标签个数总数不能超过30个!不允许再添加新分类,如有需求,请联系管理员。', "提示"); + } + } + + $scope.addTag = function(tag) { + console.log(tag); + return; + if ($scope.tags.length >= 30) { + toastr.error('标签个数总数不能超过30个!不允许再添加新分类,如有需求,请联系管理员。', "提示"); + return; + } + tag = tag.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, ' '); // 去除前后空格,多个空格转为一个空格; + if (tag) { + ngDialog.close(dialog); + + var tags = []; + tags.push(tag); + bookmarkService.addTags(tags) + .then((data) => { + toastr.success('[ ' + tag + ' ]插入分类成功!将自动更新分类信息', "提示"); + getTags({}); + }) + .catch((err) => { + toastr.warning('[ ' + tag + ' ]插入分类失败:' + JSON.stringify(err), "提示"); + }); + } else { + toastr.warning('您可能没有输入分类或者输入的分类有误', "提示"); + } + } + pubSubService.subscribe('MenuCtr.showAddBookmarkMoadl', $scope, function(event, params) { console.log('subscribe MenuCtr.showAddBookmarkMoadl', params); $('.ui.modal.js-add-bookmark').modal({ @@ -241,6 +282,12 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'bookmar if (a.last_use > b.last_use) return -1; return 1; }) + data.forEach((tag) => { + tag.clicked = false; + }) + if ($scope.add && data.length >= 1) { + data[0].clicked = true; + } $scope.tags = data; initJsTags(); $('.ui.modal.js-add-bookmark .ui.dropdown').removeClass('loading'); diff --git a/public/views/edit.html b/public/views/edit.html index d233b74..46cc5f7 100644 --- a/public/views/edit.html +++ b/public/views/edit.html @@ -5,15 +5,19 @@
-
- - -
-
- - -
+
+
+ + +
+
+ + +
+
+
+ + +
+ +
{{ tag.name }}
+
+ +
+
-