From ee86b983fd5b02ba52bfe47cbea52413be8aab73 Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Thu, 13 Dec 2018 21:52:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=BA=E6=99=AF=E7=B1=BB=E5=88=AB=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=98=BE=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/assets/css/main.css | 2 +- .../src/editor/window/CategoryEditWindow.js | 94 +++++++++++++++++++ .../src/editor/window/SceneEditWindow.js | 18 +++- 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 ShadowEditor.Web/src/editor/window/CategoryEditWindow.js diff --git a/ShadowEditor.Web/assets/css/main.css b/ShadowEditor.Web/assets/css/main.css index 757c40d1..8dd46319 100644 --- a/ShadowEditor.Web/assets/css/main.css +++ b/ShadowEditor.Web/assets/css/main.css @@ -227,7 +227,7 @@ div.Window .header .CloseButton { div.Window .body { position: relative; - height: calc(100% - 35px); + max-height: calc(100% - 35px); background-color: #eee; flex: 1; padding: 8px; diff --git a/ShadowEditor.Web/src/editor/window/CategoryEditWindow.js b/ShadowEditor.Web/src/editor/window/CategoryEditWindow.js new file mode 100644 index 00000000..930fcc8e --- /dev/null +++ b/ShadowEditor.Web/src/editor/window/CategoryEditWindow.js @@ -0,0 +1,94 @@ +import UI from '../../ui/UI'; +import Ajax from '../../utils/Ajax'; + +/** + * 类别编辑窗口 + * @author tengge / https://github.com/tengge1 + * @param {*} options + */ +function CategoryEditWindow(options = {}) { + UI.Control.call(this, options); + + this.app = options.app; + this.type = options.type || 'scene'; // 类型类型:scene, model, map, texture, audio, particle +} + +CategoryEditWindow.prototype = Object.create(UI.Control.prototype); +CategoryEditWindow.prototype.constructor = CategoryEditWindow; + +CategoryEditWindow.prototype.render = function () { + var container = UI.create({ + xtype: 'window', + id: 'window', + scope: this.id, + parent: this.parent, + title: '编辑类别', + width: '400px', + height: '320px', + shade: true, + bodyStyle: { + padding: 0 + }, + children: [{ + xtype: 'row', + style: { + padding: '2px', + boxSizing: 'border-box' + }, + children: [{ + xtype: 'button', + text: '添加' + }, { + xtype: 'button', + text: '编辑' + }, { + xtype: 'button', + text: '删除' + }] + }, { + xtype: 'datatable', + id: 'list', + scope: this.id, + cols: [{ + field: 'Name', + title: '名称' + }], + style: { + width: '100%', + height: 'calc(100% - 35px)', + padding: '4px', + boxSizing: 'border-box' + } + }] + }); + container.render(); +}; + +CategoryEditWindow.prototype.show = function () { + UI.get('window', this.id).show(); + + this.renderData(); +}; + +CategoryEditWindow.prototype.hide = function () { + UI.get('window', this.id).hide(); +}; + +CategoryEditWindow.prototype.renderData = function () { + var list = UI.get('list', this.id); + + list.clear(); + + if (this.type === 'scene') { + fetch(`/api/SceneCategory/List`).then(response => { + if (response.ok) { + response.json().then(json => { + list.rows = json.Data; + list.reload(); + }); + } + }); + } +}; + +export default CategoryEditWindow; \ No newline at end of file diff --git a/ShadowEditor.Web/src/editor/window/SceneEditWindow.js b/ShadowEditor.Web/src/editor/window/SceneEditWindow.js index 2fa84a79..56a9d4c9 100644 --- a/ShadowEditor.Web/src/editor/window/SceneEditWindow.js +++ b/ShadowEditor.Web/src/editor/window/SceneEditWindow.js @@ -1,4 +1,5 @@ import UI from '../../ui/UI'; +import CategoryEditWindow from './CategoryEditWindow'; import Ajax from '../../utils/Ajax'; /** @@ -53,7 +54,8 @@ SceneEditWindow.prototype.render = function () { position: 'absolute', right: 0, marginRight: '24px' - } + }, + onClick: this.onEditCategory.bind(this) }] }, { xtype: 'row', @@ -165,4 +167,18 @@ SceneEditWindow.prototype.save = function () { }); }; +// ----------------------------- 类别编辑 ---------------------------------------- + +SceneEditWindow.prototype.onEditCategory = function () { + if (this.editCategoryWin === undefined) { + this.editCategoryWin = new CategoryEditWindow({ + app: this.app, + type: 'scene' + }); + this.editCategoryWin.render(); + } + + this.editCategoryWin.show(); +}; + export default SceneEditWindow; \ No newline at end of file