Commit 5d75d49a authored by antoor's avatar antoor

增加shell管理界面数据分类重命名功能

parent 73a66dd1
......@@ -4,6 +4,9 @@
## 2016/03
### /22
1. 数据分类重命名
### /21
1. 优化UI组建自适应,在调整窗口大小的时候不刷新就能调整UI尺寸
......@@ -21,8 +24,18 @@
### /13
1. 修复源码中`jquery`库缺失问题
# 待做事项
* 数据分类重命名
* 数据高级搜索功能
* 数据库配置编辑功能
* 数据发包代理功能
* 在线检测/下载/安装更新
* 重写优化数据处理截断算法
* 虚拟终端复制粘贴tab补全
* 文件管理双击文件进行编辑 //size < 1024kb
* 插件模块 //实时编写插件执行、UI以及各种操作API设计
* 扩展模块 //用于扩展一些高级的功能,懒人必备
* 代码重构
* 中文开发文档
* 英文说明+开发文档
* nodejs服务端脚本支持
* python服务端脚本支持
\ No newline at end of file
......@@ -155,6 +155,22 @@ class Database {
event.returnValue = err || num;
})
})
// 重命名分类
// {oldName, newName}
.on('shell-renameCategory', (event, arg) => {
logger.warn('shell-renameCategory', arg);
this.cursor.update({
category: arg['oldName']
}, {
$set: {
category: arg['newName']
}
}, {
multi: true
}, (err, num) => {
event.returnValue = err || num;
})
})
// 移动数据
.on('shell-move', (event, arg) => {
logger.info('shell-move', arg);
......
......@@ -63,7 +63,8 @@ module.exports = {
default: 'Default',
toolbar: {
add: 'Add',
del: 'Del'
del: 'Del',
rename: 'Rename'
},
add: {
title: 'Add category'
......@@ -73,6 +74,13 @@ module.exports = {
confirm: 'Are you sure to delete this category?',
success: (category) => antSword.noxss(`Delete category(${category}) success!`),
error: (category, err) => antSword.noxss(`Delete category(${category}failed!<br/>${err}`)
},
rename: {
title: 'Rename category',
disable: 'Prohibited category name!',
exists: 'This category name already exists!',
success: 'Successful rename!',
error: 'Rename category failed!'
}
},
list: {
......
......@@ -64,7 +64,8 @@ module.exports = {
default: '默认分类',
toolbar: {
add: '添加',
del: '删除'
del: '删除',
rename: '重命名'
},
add: {
title: '添加分类'
......@@ -74,6 +75,13 @@ module.exports = {
confirm: '确定删除此分类吗?(数据将清空)',
success: (category) => antSword.noxss(`成功删除分类(${category})!`),
error: (category, err) => antSword.noxss(`删除分类(${category})失败!<br/>${err}`)
},
rename: {
title: '重命名分类',
disable: '禁止的分类名称!',
exists: '此分类名已经存在!',
success: '重命名分类成功!',
error: '重命名分类失败!'
}
},
list: {
......
......@@ -19,6 +19,8 @@ class Category {
toolbar.loadStruct([
{ id: 'add', type: 'button', text: `<i class="fa fa-plus-circle"></i> ${LANG['category']['toolbar']['add']}` },
{ type: 'separator' },
{ id: 'rename', type: 'button', text: `<i class="fa fa-font"></i> ${LANG['category']['toolbar']['rename']}`, disabled: true },
{ type: 'separator' },
{ id: 'del', type: 'button', text: `<i class="fa fa-trash"></i> ${LANG['category']['toolbar']['del']}`, disabled: true }
]);
// toolbar点击
......@@ -34,6 +36,47 @@ class Category {
sidebar.callEvent('onSelect', [value]);
});
break;
case 'rename':
// 重命名分类
const _category = sidebar.getActiveItem();
layer.prompt({
title: `<i class="fa fa-font"></i> ${LANG['category']['rename']['title']}`,
value: _category
}, (value, index, ele) => {
// 禁止的分类名
if (value === 'default') {
return toastr.warning(LANG['category']['rename']['disable'], LANG_T['warning']);
};
// 判断分类是否存在
if (sidebar.items(value)) {
return toastr.warning(LANG['category']['rename']['exists'], LANG_T['warning']);
};
layer.close(index);
// 更新数据库
const ret = antSword['ipcRenderer'].sendSync('shell-renameCategory', {
oldName: _category,
newName: value
});
if (typeof ret === 'number') {
// 更新成功
toastr.success(LANG['category']['rename']['success'], LANG_T['success']);
// 删除旧分类
sidebar.items(_category).remove();
// 添加新分类
sidebar.addItem({
id: value,
bubble: ret,
text: `<i class="fa fa-folder-o"></i> ${value}`
});
// 跳转分类
setTimeout(() => {
sidebar.items(value).setActive();
}, 233);
}else{
toastr.error(LANG['category']['rename']['error'], LANG_T['error']);
}
});
break;
case 'del':
// 删除分类
const category = sidebar.getActiveItem();
......@@ -77,6 +120,7 @@ class Category {
sidebar.attachEvent('onSelect', (id) => {
// 更改删除按钮状态
toolbar[(id === 'default') ? 'disableItem' : 'enableItem']('del');
toolbar[(id === 'default') ? 'disableItem' : 'enableItem']('rename');
manager.loadData({
category: id
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment