在分类界面添加新增分类功能
This commit is contained in:
parent
1eb1266d8b
commit
ba5cff823e
|
|
@ -459,12 +459,12 @@ db.getTagsByNames = function(user_id, tags_name) {
|
|||
|
||||
db.addTags = function(user_id, tags_name) {
|
||||
console.log('addTags', tags_name);
|
||||
var sql = "INSERT INTO `tags` (`user_id`, `name`) VALUES";
|
||||
var sql = "INSERT INTO `tags` (`user_id`, `name`, `sort`) VALUES";
|
||||
tags_name.forEach((name, i) => {
|
||||
if (i >= 1) {
|
||||
sql += ','
|
||||
}
|
||||
sql += "('" + user_id + "', '" + name + "')";
|
||||
sql += "('"+ user_id +"', '"+ name +"', '88')"; // sort默认一个比较大的值,默认在后面
|
||||
});
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (tags_name.length == 0) {
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 687 B |
|
|
@ -42,7 +42,7 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', 'bookmarkService', 'p
|
|||
});
|
||||
|
||||
if (tags.length + $scope.tags.length >= 30) {
|
||||
toastr.error('标签个数总数不能超过30个!', "提示");
|
||||
toastr.error('标签个数总数不能超过30个!不允许再添加新分类,如有需求,请联系管理员。', "提示");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim
|
|||
$scope.inputPage = '';
|
||||
$scope.currentTagId = ($stateParams && $stateParams.tagId) || '';
|
||||
$scope.edit = false;
|
||||
$scope.newTag = '';
|
||||
$scope.waitDelTag = {};
|
||||
$scope.waitDelBookmark = {};
|
||||
|
||||
|
|
@ -202,6 +203,40 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim
|
|||
});
|
||||
}
|
||||
|
||||
$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) {
|
||||
ngDialog.close(dialog);
|
||||
console.log(tag);
|
||||
tag = tag.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, ' '); // 去除前后空格,多个空格转为一个空格;
|
||||
if (tag) {
|
||||
var tags = [];
|
||||
tags.push(tag);
|
||||
bookmarkService.addTags(tags)
|
||||
.then((data) => {
|
||||
toastr.success('插入分类成功!将自动更新分类信息', "提示");
|
||||
getTags({});
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.warning('插入分类失败:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
} else {
|
||||
toastr.warning('您可能没有输入分类或者输入的分类有误', "提示");
|
||||
}
|
||||
}
|
||||
|
||||
$scope.backTag = function(tag) {
|
||||
tag.edit = false;
|
||||
tag.name = tag.oldName;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
<div class="ngdialog-message">
|
||||
<h3>新建分类</h3>
|
||||
</div>
|
||||
<div class="dialog-contents">
|
||||
新分类:<input type="text" ng-model="newTag">
|
||||
</div>
|
||||
<p></p>
|
||||
<div class="ngdialog-buttons">
|
||||
<button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="addTag(newTag)">确定</button>
|
||||
<button type="button" class="ngdialog-button ngdialog-button-secondary" ng-click="closeThisDialog('button')">取消</button>
|
||||
</div>
|
||||
|
|
@ -34,6 +34,11 @@
|
|||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" ng-click="showAddTag()">
|
||||
<div class="image">
|
||||
<img src="./images/add-tag.png">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width:22px;height:22px;" class="js-edit" ng-click="toggleMode()" title="{{edit ? '退出编辑模式' : '点我进入编辑模式'}}"><img class="ui ui middle aligned tiny image" ng-src="./images/{{ edit ? 'back' : 'edit'}}.png"></div>
|
||||
|
|
|
|||
|
|
@ -545,13 +545,13 @@ api.post('/uploadBookmarkFile', upload.single('bookmark'), function(req, res) {
|
|||
|
||||
var tags = [];
|
||||
item.tags.forEach((tag) => {
|
||||
allTags.forEach((at) => {
|
||||
if (at.name == tag) {
|
||||
tags.push(at.id);
|
||||
}
|
||||
allTags.forEach((at) => {
|
||||
if (at.name == tag) {
|
||||
tags.push(at.id);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
// 插入书签
|
||||
// 插入书签
|
||||
db.addBookmark(userId, bookmark) // 插入书签
|
||||
.then((bookmark_id) => {
|
||||
db.delBookmarkTags(bookmark_id); // 不管3721,先删掉旧的分类
|
||||
|
|
@ -747,18 +747,23 @@ api.post('/getArticle', function(req, res) {
|
|||
var url = params.url;
|
||||
var requestId = params.requestId || 0;
|
||||
read(url, function(err, article, meta) {
|
||||
console.log(article.title || 'Get title failed');
|
||||
if (requestId == 0) {
|
||||
if (err) {
|
||||
res.json({
|
||||
title: article.title || '',
|
||||
});
|
||||
} else if (requestId == 1) {
|
||||
res.json({
|
||||
content: article.content,
|
||||
title: '',
|
||||
content: false,
|
||||
});
|
||||
} else {
|
||||
if (requestId == 0) {
|
||||
res.json({
|
||||
title: article.title || '',
|
||||
});
|
||||
} else if (requestId == 1) {
|
||||
res.json({
|
||||
content: article.content,
|
||||
});
|
||||
}
|
||||
article.close();
|
||||
}
|
||||
|
||||
article.close();
|
||||
});
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue