From e23ed3be2d9775e68ea8ab4f24854dd692139330 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Thu, 29 Mar 2018 19:45:57 +0800 Subject: [PATCH 1/7] =?UTF-8?q?#IINTK=20=E6=B2=9F=E9=80=9A=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E9=A1=B5=E9=9D=A2=E5=BD=93window=20resize=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=87=8D=E6=96=B0=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/chat-direct.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/chat/chat-direct.js b/src/chat/chat-direct.js index cde1be7..2e7a471 100644 --- a/src/chat/chat-direct.js +++ b/src/chat/chat-direct.js @@ -42,9 +42,24 @@ export class ChatDirect { toastr.error('复制到剪贴板失败!'); }); + $(window).resize((event) => { + this.doResize(); + }); + this.initSubscribeEvent(); } + doResize() { + if (nsCtx.isRightSidebarShow) { + let wid = $(this.contentRef).width() - 392; + $(this.contentBodyRef).width(wid); + $(this.contentBodyRef).children('.scroll-wrapper').width(wid); + } else { + $(this.contentBodyRef).css('width', '100%'); + $(this.contentBodyRef).children('.scroll-wrapper').css('width', '100%'); + } + } + initSubscribeEvent() { this.subscribe = ea.subscribe(nsCons.EVENT_CHAT_MSG_SENDED, (payload) => { @@ -63,14 +78,7 @@ export class ChatDirect { this.subscribe2 = ea.subscribe(nsCons.EVENT_CHAT_SIDEBAR_TOGGLE, (payload) => { this.isRightSidebarShow = nsCtx.isRightSidebarShow = payload.isShow; - if (this.isRightSidebarShow) { - let wid = $(this.contentRef).width() - 392; - $(this.contentBodyRef).width(wid); - $(this.contentBodyRef).children('.scroll-wrapper').width(wid); - } else { - $(this.contentBodyRef).css('width', '100%'); - $(this.contentBodyRef).children('.scroll-wrapper').css('width', '100%'); - } + this.doResize(); }); this.subscribe3 = ea.subscribe(nsCons.EVENT_CHAT_CHANNEL_CREATED, (payload) => { -- Gitee From 4441566a2ff0e8e9d740c88504d57df15090cccb Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Sat, 31 Mar 2018 09:03:10 +0800 Subject: [PATCH 2/7] todo list ui --- src/common/common-constant.js | 1 + src/resources/elements/em-chat-sidebar-right.js | 5 +++++ src/resources/elements/em-chat-top-menu.html | 12 ++++++++++++ src/resources/elements/em-chat-top-menu.js | 15 +++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/src/common/common-constant.js b/src/common/common-constant.js index 7e54480..fd243b6 100644 --- a/src/common/common-constant.js +++ b/src/common/common-constant.js @@ -63,6 +63,7 @@ window.nsCons = { ACTION_TYPE_DIR: 'action_type_dir', ACTION_TYPE_ATTACH: 'action_type_attach', ACTION_TYPE_SCHEDULE: 'action_type_schedule', + ACTION_TYPE_TODO: 'action_type_todo', NUM_TEXT_COMPLETE_MAX_COUNT: 20, STR_EMOJI_SEARCH_URL: 'http://emoji.muan.co/', KEY_REMEMBER_LAST_CHAT_TO: 'tms/remember_last_chat_to', diff --git a/src/resources/elements/em-chat-sidebar-right.js b/src/resources/elements/em-chat-sidebar-right.js index d82fd5b..345f98d 100644 --- a/src/resources/elements/em-chat-sidebar-right.js +++ b/src/resources/elements/em-chat-sidebar-right.js @@ -16,6 +16,7 @@ export class EmChatSidebarRight { [nsCons.ACTION_TYPE_SEARCH]: { nodata: '无符合检索结果', show: 'msg', icon: 'search', title: '检索结果' }, [nsCons.ACTION_TYPE_PIN]: { nodata: '暂无频道固定消息', show: 'msg', icon: 'pin', title: '频道固定消息' }, [nsCons.ACTION_TYPE_TOPIC]: { nodata: '', show: 'topic', icon: 'talk outline', title: '话题讨论' }, + [nsCons.ACTION_TYPE_TODO]: { handler: this.todoHandler, nodata: '暂无待办事项', show: 'todo', icon: 'tasks', title: '待办事项' }, } /** @@ -57,6 +58,10 @@ export class EmChatSidebarRight { this.chatScheduleVm.show(); } + todoHandler(payload) { + this.chatScheduleVm.show(); + } + closeHandler() { ea.publish(nsCons.EVENT_CHAT_TOGGLE_RIGHT_SIDEBAR, {}); } diff --git a/src/resources/elements/em-chat-top-menu.html b/src/resources/elements/em-chat-top-menu.html index b4cacce..7934a60 100644 --- a/src/resources/elements/em-chat-top-menu.html +++ b/src/resources/elements/em-chat-top-menu.html @@ -107,6 +107,12 @@
+
+ +
diff --git a/src/resources/elements/em-chat-top-menu.js b/src/resources/elements/em-chat-top-menu.js index caf3980..1b4f113 100644 --- a/src/resources/elements/em-chat-top-menu.js +++ b/src/resources/elements/em-chat-top-menu.js @@ -21,6 +21,7 @@ export class EmChatTopMenu { ACTION_TYPE_DIR = nsCons.ACTION_TYPE_DIR; ACTION_TYPE_ATTACH = nsCons.ACTION_TYPE_ATTACH; ACTION_TYPE_SCHEDULE = nsCons.ACTION_TYPE_SCHEDULE; + ACTION_TYPE_TODO = nsCons.ACTION_TYPE_TODO; countAt = null; newAtCnt = 0; @@ -374,6 +375,20 @@ export class EmChatTopMenu { this.toggleRightSidebar(true); } + showTodoHandler(event) { + + if (this.isRightSidebarShow && (this.activeType == nsCons.ACTION_TYPE_TODO) && !event.ctrlKey) { + this.toggleRightSidebar(); + return; + } + + this.activeType = nsCons.ACTION_TYPE_TODO; + ea.publish(nsCons.EVENT_CHAT_RIGHT_SIDEBAR_TOGGLE, { + action: this.activeType + }); + this.toggleRightSidebar(true); + } + userEditHandler() { this.userEditMd.show(); } -- Gitee From 374f26184630f3512271ce2d99982841a5d552a2 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Sat, 31 Mar 2018 09:10:16 +0800 Subject: [PATCH 3/7] todo icon --- src/resources/elements/em-chat-top-menu.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resources/elements/em-chat-top-menu.html b/src/resources/elements/em-chat-top-menu.html index 7934a60..2228f5b 100644 --- a/src/resources/elements/em-chat-top-menu.html +++ b/src/resources/elements/em-chat-top-menu.html @@ -109,7 +109,7 @@
@@ -151,7 +151,7 @@
-- Gitee From c251d87dada7a9a5462945227b3f1d9679223e0e Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Sat, 31 Mar 2018 10:12:05 +0800 Subject: [PATCH 4/7] todo ui --- .../elements/em-chat-sidebar-right.html | 1 + .../elements/em-chat-sidebar-right.js | 2 +- src/resources/elements/em-chat-todo.html | 47 +++++++++++++++++++ src/resources/elements/em-chat-todo.js | 27 +++++++++++ src/resources/elements/em-chat-todo.less | 1 + src/resources/index.js | 1 + 6 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/resources/elements/em-chat-todo.html create mode 100644 src/resources/elements/em-chat-todo.js create mode 100644 src/resources/elements/em-chat-todo.less diff --git a/src/resources/elements/em-chat-sidebar-right.html b/src/resources/elements/em-chat-sidebar-right.html index fb6fa51..daeae28 100644 --- a/src/resources/elements/em-chat-sidebar-right.html +++ b/src/resources/elements/em-chat-sidebar-right.html @@ -20,6 +20,7 @@ + diff --git a/src/resources/elements/em-chat-sidebar-right.js b/src/resources/elements/em-chat-sidebar-right.js index 345f98d..601f5e0 100644 --- a/src/resources/elements/em-chat-sidebar-right.js +++ b/src/resources/elements/em-chat-sidebar-right.js @@ -59,7 +59,7 @@ export class EmChatSidebarRight { } todoHandler(payload) { - this.chatScheduleVm.show(); + // this.chatScheduleVm.show(); } closeHandler() { diff --git a/src/resources/elements/em-chat-todo.html b/src/resources/elements/em-chat-todo.html new file mode 100644 index 0000000..8bef04a --- /dev/null +++ b/src/resources/elements/em-chat-todo.html @@ -0,0 +1,47 @@ + diff --git a/src/resources/elements/em-chat-todo.js b/src/resources/elements/em-chat-todo.js new file mode 100644 index 0000000..f6a99fa --- /dev/null +++ b/src/resources/elements/em-chat-todo.js @@ -0,0 +1,27 @@ +import { bindable, containerless } from 'aurelia-framework'; + +@containerless +export class EmChatTodo { + + @bindable actived; + loginUser = nsCtx.loginUser; + + activedChanged(newValue, oldValue) { + if (!newValue || this.actived.payload.action != nsCons.ACTION_TYPE_TODO) { + return; + } + + this.listMy(); + } + + listMy() { + $.get('/admin/todo/listMy', {}, (data) => { + if (data.success) { + this.todos = data.data; + } else { + toastr.error(data.data, '获取待办事项列表失败!'); + } + }); + } + +} diff --git a/src/resources/elements/em-chat-todo.less b/src/resources/elements/em-chat-todo.less new file mode 100644 index 0000000..8ba6ded --- /dev/null +++ b/src/resources/elements/em-chat-todo.less @@ -0,0 +1 @@ +.em-chat-todo {} \ No newline at end of file diff --git a/src/resources/index.js b/src/resources/index.js index 8140adb..7f4a820 100644 --- a/src/resources/index.js +++ b/src/resources/index.js @@ -61,6 +61,7 @@ export function configure(aurelia) { 'resources/elements/em-chat-topic', 'resources/elements/em-chat-topic-input', 'resources/elements/em-chat-settings', + 'resources/elements/em-chat-todo', 'resources/elements/em-blog-write', 'resources/elements/em-blog-left-sidebar', 'resources/elements/em-blog-right-sidebar', -- Gitee From 9860f2131b809558fd95156dbf4b002d0c37c844 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Sat, 31 Mar 2018 13:43:10 +0800 Subject: [PATCH 5/7] todo --- .../elements/em-chat-sidebar-right.js | 2 +- src/resources/elements/em-chat-todo.html | 60 ++++++++------- src/resources/elements/em-chat-todo.js | 73 ++++++++++++++++++- src/resources/elements/em-chat-todo.less | 26 ++++++- 4 files changed, 131 insertions(+), 30 deletions(-) diff --git a/src/resources/elements/em-chat-sidebar-right.js b/src/resources/elements/em-chat-sidebar-right.js index 601f5e0..ff5df86 100644 --- a/src/resources/elements/em-chat-sidebar-right.js +++ b/src/resources/elements/em-chat-sidebar-right.js @@ -16,7 +16,7 @@ export class EmChatSidebarRight { [nsCons.ACTION_TYPE_SEARCH]: { nodata: '无符合检索结果', show: 'msg', icon: 'search', title: '检索结果' }, [nsCons.ACTION_TYPE_PIN]: { nodata: '暂无频道固定消息', show: 'msg', icon: 'pin', title: '频道固定消息' }, [nsCons.ACTION_TYPE_TOPIC]: { nodata: '', show: 'topic', icon: 'talk outline', title: '话题讨论' }, - [nsCons.ACTION_TYPE_TODO]: { handler: this.todoHandler, nodata: '暂无待办事项', show: 'todo', icon: 'tasks', title: '待办事项' }, + [nsCons.ACTION_TYPE_TODO]: { handler: this.todoHandler, nodata: '暂无待办事项', show: 'todo', icon: 'ordered list', title: '待办事项' }, } /** diff --git a/src/resources/elements/em-chat-todo.html b/src/resources/elements/em-chat-todo.html index 8bef04a..deda6f7 100644 --- a/src/resources/elements/em-chat-todo.html +++ b/src/resources/elements/em-chat-todo.html @@ -3,42 +3,50 @@
- - + +

- - 正在进行 + + 进行中(${todos.length})

-
-
- -
- xxxxxxxxxxxxxxxxxxxxxxxxxxxx... +
+
+
+ + +
-
-
- -
- xxxxxxxxxxxxxxxxxxxxxxxxxxxx... + +
+ ${item.title}

- - 已经完成 + + 已完成(${dones.length})

-
-
- -
- xxxxxxxxxxxxxxxxxxxxxxxxxxxx... +
+
+
+ + +
-
-
- -
- xxxxxxxxxxxxxxxxxxxxxxxxxxxx... + +
+ ${item.title}
diff --git a/src/resources/elements/em-chat-todo.js b/src/resources/elements/em-chat-todo.js index f6a99fa..020d5d0 100644 --- a/src/resources/elements/em-chat-todo.js +++ b/src/resources/elements/em-chat-todo.js @@ -5,6 +5,9 @@ export class EmChatTodo { @bindable actived; loginUser = nsCtx.loginUser; + title; + todos = []; + dones = []; activedChanged(newValue, oldValue) { if (!newValue || this.actived.payload.action != nsCons.ACTION_TYPE_TODO) { @@ -15,13 +18,79 @@ export class EmChatTodo { } listMy() { - $.get('/admin/todo/listMy', {}, (data) => { + this.ajax = $.get('/admin/todo/listMy', {}, (data) => { if (data.success) { - this.todos = data.data; + this.todos = _.reject(data.data, { status: 'Done' }); + this.dones = _.filter(data.data, { status: 'Done' }); } else { toastr.error(data.data, '获取待办事项列表失败!'); } }); } + addTodoHandler() { + + $(this.todoInputRef).focus(); + + if (!this.title) { + toastr.error('请输入待办事项内容!'); + return; + } + + this.ajax = $.post('/admin/todo/create', { title: this.title }, (data, textStatus, xhr) => { + if (data.success) { + this.title = ''; + this.todos = [data.data, ...this.todos]; + } else { + toastr.error(data.data, '创建待办事项失败!'); + } + }); + } + + statusToggleHandler(item) { + $.post('/admin/todo/update', { id: item.id, status: item.status == 'New' ? 'Doing' : "New" }, (data, textStatus, xhr) => { + if (data.success) { + item.status = data.data.status; + } else { + toastr.error(data.data, '更新待办事项失败!'); + } + }); + } + + statusDoneHandler(item) { + $.post('/admin/todo/update', { id: item.id, status: 'Done' }, (data, textStatus, xhr) => { + if (data.success) { + this.todos = _.reject(this.todos, { id: item.id }); + this.dones = [data.data, ...this.dones]; + } else { + toastr.error(data.data, '更新待办事项失败!'); + } + }); + } + + statusNewHandler(item) { + $.post('/admin/todo/update', { id: item.id, status: 'New' }, (data, textStatus, xhr) => { + if (data.success) { + this.dones = _.reject(this.dones, { id: item.id }); + this.todos = [data.data, ...this.todos]; + } else { + toastr.error(data.data, '更新待办事项失败!'); + } + }); + } + + delHandler(item, type) { + $.post(`/admin/todo/delete/${item.id}`, {}, (data, textStatus, xhr) => { + if (data.success) { + if (type == 'todo') { + this.todos = _.reject(this.todos, { id: item.id }); + } else { + this.dones = _.reject(this.dones, { id: item.id }); + } + } else { + toastr.error(data.data, '删除待办事项失败!'); + } + }); + } + } diff --git a/src/resources/elements/em-chat-todo.less b/src/resources/elements/em-chat-todo.less index 8ba6ded..2afcedd 100644 --- a/src/resources/elements/em-chat-todo.less +++ b/src/resources/elements/em-chat-todo.less @@ -1 +1,25 @@ -.em-chat-todo {} \ No newline at end of file +.em-chat-todo { + .ui.list { + .item { + .content { + text-overflow: ellipsis; + overflow: hidden; + max-width: 300px; + } + .actions { + display: none; + position: absolute; + right: 10px; + > i.icon { + margin-right: 0; + } + } + + &:hover { + .actions { + display: inline-block; + } + } + } + } +} -- Gitee From 952a7107af0229c1a9fa24dc718c164623abd6d2 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Sat, 31 Mar 2018 14:16:14 +0800 Subject: [PATCH 6/7] style --- index.html | 2 +- src/environment.js | 4 ++-- src/resources/elements/em-chat-todo.html | 12 ++++++------ src/resources/elements/em-chat-todo.less | 21 ++++++++++++--------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 1dd3448..fbbd742 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ - + diff --git a/src/environment.js b/src/environment.js index 3495e9a..da32a4b 100644 --- a/src/environment.js +++ b/src/environment.js @@ -1,4 +1,4 @@ export default { - debug: true, - testing: true + debug: false, + testing: false }; diff --git a/src/resources/elements/em-chat-todo.html b/src/resources/elements/em-chat-todo.html index deda6f7..df63496 100644 --- a/src/resources/elements/em-chat-todo.html +++ b/src/resources/elements/em-chat-todo.html @@ -6,10 +6,10 @@
-

+

进行中(${todos.length}) -
+
@@ -22,16 +22,16 @@
- -
+ +
${item.title}
-

+

已完成(${dones.length}) -
+
diff --git a/src/resources/elements/em-chat-todo.less b/src/resources/elements/em-chat-todo.less index 2afcedd..8ece467 100644 --- a/src/resources/elements/em-chat-todo.less +++ b/src/resources/elements/em-chat-todo.less @@ -5,20 +5,23 @@ text-overflow: ellipsis; overflow: hidden; max-width: 300px; + &.red { + color: red; + } } .actions { - display: none; - position: absolute; - right: 10px; - > i.icon { - margin-right: 0; - } + display: none; + position: absolute; + right: 10px; + >i.icon { + margin-right: 0; + } } &:hover { - .actions { - display: inline-block; - } + .actions { + display: inline-block; + } } } } -- Gitee From 80bf8daa9814698f81b8ace68d055c017699e03b Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Sat, 31 Mar 2018 19:42:55 +0800 Subject: [PATCH 7/7] todo edit --- build.sh | 26 ++++++++++++++++++++++++ index.html | 2 +- src/resources/elements/em-chat-todo.html | 22 +++++++++++++------- src/resources/elements/em-chat-todo.js | 24 ++++++++++++++++++++-- src/resources/elements/em-chat-todo.less | 3 +++ 5 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..219f97e --- /dev/null +++ b/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +echo "build start" + +DEST=/Users/xiweicheng/tms/src/main/resources/static +SRC=/Users/xiweicheng/tms-frontend + +echo "DEST DIR: $DEST" +echo "SRC DIR: $SRC" + +echo "au pkg --env prod" + +cd $SRC +au pkg --env prod + +echo "rm page/scripts & page/index.html" + +rm -rf $DEST/page/scripts +rm -rf $DEST/page/index.html + +echo "cp tms-frontend to tms" + +cp -rf $SRC/scripts $DEST/page +cp -rf $SRC/index.html $DEST/page + +echo "build end" \ No newline at end of file diff --git a/index.html b/index.html index fbbd742..0f074f4 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ - + diff --git a/src/resources/elements/em-chat-todo.html b/src/resources/elements/em-chat-todo.html index df63496..c82a093 100644 --- a/src/resources/elements/em-chat-todo.html +++ b/src/resources/elements/em-chat-todo.html @@ -1,7 +1,7 @@