From a5f662e43fcfa0c270de0663d1b9ce7c72a3bee7 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Mon, 31 Jan 2022 16:07:56 +0700 Subject: [PATCH] Ability to change done state (#888) Signed-off-by: Andrey Sobolev --- models/task/src/index.ts | 8 ++ models/task/src/plugin.ts | 1 + .../src/components/AttributeBarEditor.svelte | 41 +++++-- plugins/task-assets/lang/en.json | 3 +- .../src/components/TaskHeader.svelte | 1 + .../components/state/DoneStateEditor.svelte | 70 ++++++++++++ .../state/DoneStatePresenter.svelte | 12 ++- .../components/state/DoneStatesPopup.svelte | 100 ++++++++++++++++++ plugins/task-resources/src/index.ts | 4 +- plugins/task-resources/src/plugin.ts | 3 +- 10 files changed, 230 insertions(+), 13 deletions(-) create mode 100644 plugins/task-resources/src/components/state/DoneStateEditor.svelte create mode 100644 plugins/task-resources/src/components/state/DoneStatesPopup.svelte diff --git a/models/task/src/index.ts b/models/task/src/index.ts index c9d6528597..82edbe5a8f 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -428,6 +428,14 @@ export function createModel (builder: Builder): void { presenter: task.component.StatePresenter }) + builder.mixin(task.class.DoneState, core.class.Class, view.mixin.AttributeEditor, { + editor: task.component.DoneStateEditor + }) + + builder.mixin(task.class.DoneState, core.class.Class, view.mixin.AttributePresenter, { + presenter: task.component.DoneStatePresenter + }) + builder.createDoc( view.class.ViewletDescriptor, core.space.Model, diff --git a/models/task/src/plugin.ts b/models/task/src/plugin.ts index 04de2c60b5..51a5f667a9 100644 --- a/models/task/src/plugin.ts +++ b/models/task/src/plugin.ts @@ -55,6 +55,7 @@ export default mergeIds(taskId, task, { StatePresenter: '' as AnyComponent, DoneStatePresenter: '' as AnyComponent, StateEditor: '' as AnyComponent, + DoneStateEditor: '' as AnyComponent, KanbanView: '' as AnyComponent, Todos: '' as AnyComponent, TodoItemPresenter: '' as AnyComponent, diff --git a/packages/presentation/src/components/AttributeBarEditor.svelte b/packages/presentation/src/components/AttributeBarEditor.svelte index 5c35cc6562..7305b3670c 100644 --- a/packages/presentation/src/components/AttributeBarEditor.svelte +++ b/packages/presentation/src/components/AttributeBarEditor.svelte @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. --> - + +
{ + if (!opened) { + opened = true + showPopup(DoneStatesPopup, { space }, container, (result) => { + if (result) { + value = result._id + onChange(value) + } else if (result == null) { + value = null + onChange(value) + } + + opened = false + }) + } + }} +> + {#if state} + + {:else} +
diff --git a/plugins/task-resources/src/components/state/DoneStatePresenter.svelte b/plugins/task-resources/src/components/state/DoneStatePresenter.svelte index dec21f59f0..eae69effcb 100644 --- a/plugins/task-resources/src/components/state/DoneStatePresenter.svelte +++ b/plugins/task-resources/src/components/state/DoneStatePresenter.svelte @@ -17,16 +17,21 @@ {#if value }
-
+
+ {#if showTitle} + {value.title} + {/if}
{/if} @@ -36,4 +41,7 @@ height: .5rem; border-radius: .5rem; } + .state-container-title { + margin-right: 0.75rem; + } diff --git a/plugins/task-resources/src/components/state/DoneStatesPopup.svelte b/plugins/task-resources/src/components/state/DoneStatesPopup.svelte new file mode 100644 index 0000000000..cd7b3b90de --- /dev/null +++ b/plugins/task-resources/src/components/state/DoneStatesPopup.svelte @@ -0,0 +1,100 @@ + + + +
+ {#each states as state} +
{ + dispatch('close', state) + }} + > +
+ {state.title} +
+ {/each} +
{ + dispatch('close', null) + }} + > +
+
+
+
+ + diff --git a/plugins/task-resources/src/index.ts b/plugins/task-resources/src/index.ts index dd6c048dc7..ed0392da70 100644 --- a/plugins/task-resources/src/index.ts +++ b/plugins/task-resources/src/index.ts @@ -26,6 +26,7 @@ import EditIssue from './components/EditIssue.svelte' import KanbanView from './components/kanban/KanbanView.svelte' import KanbanCard from './components/KanbanCard.svelte' import DoneStatePresenter from './components/state/DoneStatePresenter.svelte' +import DoneStateEditor from './components/state/DoneStateEditor.svelte' import EditStatuses from './components/state/EditStatuses.svelte' import StateEditor from './components/state/StateEditor.svelte' import StatePresenter from './components/state/StatePresenter.svelte' @@ -140,7 +141,8 @@ export default async (): Promise => ({ TodoItemPresenter, TodoStatePresenter, StatusTableView, - TaskHeader + TaskHeader, + DoneStateEditor }, actionImpl: { CreateTask: createTask, diff --git a/plugins/task-resources/src/plugin.ts b/plugins/task-resources/src/plugin.ts index f3ae5f5d45..690117cf6d 100644 --- a/plugins/task-resources/src/plugin.ts +++ b/plugins/task-resources/src/plugin.ts @@ -58,7 +58,8 @@ export default mergeIds(taskId, task, { DoneStatesWon: '' as IntlString, DoneStatesLost: '' as IntlString, AllStates: '' as IntlString, - ChooseAColor: '' as IntlString + ChooseAColor: '' as IntlString, + NoDoneState: '' as IntlString }, status: { AssigneeRequired: '' as IntlString