Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags: Add inline editor #2081

Merged
merged 4 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/board/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export function createModel (builder: Builder): void {
})

builder.mixin(board.class.CardCover, core.class.Class, view.mixin.AttributeEditor, {
editor: board.component.CardCoverEditor
inlineEditor: board.component.CardCoverEditor
})

builder.createDoc(
Expand Down
8 changes: 4 additions & 4 deletions models/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,27 @@ export function createModel (builder: Builder): void {
})

builder.mixin(contact.class.Organization, core.class.Class, view.mixin.AttributeEditor, {
editor: contact.component.OrganizationEditor
inlineEditor: contact.component.OrganizationEditor
})

builder.mixin(contact.class.Member, core.class.Class, view.mixin.CollectionEditor, {
editor: contact.component.Members
})

builder.mixin(contact.class.Employee, core.class.Class, view.mixin.ArrayEditor, {
editor: contact.component.EmployeeArrayEditor
inlineEditor: contact.component.EmployeeArrayEditor
})

builder.mixin(contact.class.Member, core.class.Class, view.mixin.AttributePresenter, {
presenter: contact.component.MemberPresenter
})

builder.mixin(contact.class.Person, core.class.Class, view.mixin.AttributeEditor, {
editor: contact.component.PersonEditor
inlineEditor: contact.component.PersonEditor
})

builder.mixin(contact.class.Employee, core.class.Class, view.mixin.AttributeEditor, {
editor: contact.component.PersonEditor
inlineEditor: contact.component.PersonEditor
})

builder.mixin(contact.class.Channel, core.class.Class, view.mixin.AttributePresenter, {
Expand Down
7 changes: 2 additions & 5 deletions models/tags/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ export function createModel (builder: Builder): void {
builder.createModel(TTagElement, TTagReference, TTagCategory)

builder.mixin(tags.class.TagReference, core.class.Class, view.mixin.CollectionEditor, {
editor: tags.component.Tags
})

builder.mixin(tags.class.TagReference, core.class.Class, view.mixin.AttributeEditor, {
editor: tags.component.TagsAttributeEditor
editor: tags.component.Tags,
inlineEditor: tags.component.TagsAttributeEditor
})

builder.mixin(tags.class.TagReference, core.class.Class, view.mixin.AttributePresenter, {
Expand Down
4 changes: 2 additions & 2 deletions models/task/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export function createModel (builder: Builder): void {
)

builder.mixin(task.class.State, core.class.Class, view.mixin.AttributeEditor, {
editor: task.component.StateEditor
inlineEditor: task.component.StateEditor
})

builder.mixin(task.class.State, core.class.Class, view.mixin.AttributePresenter, {
Expand All @@ -446,7 +446,7 @@ export function createModel (builder: Builder): void {
})

builder.mixin(task.class.DoneState, core.class.Class, view.mixin.AttributeEditor, {
editor: task.component.DoneStateEditor
inlineEditor: task.component.DoneStateEditor
})

builder.mixin(task.class.DoneState, core.class.Class, view.mixin.AttributePresenter, {
Expand Down
2 changes: 1 addition & 1 deletion models/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export function createModel (builder: Builder): void {
builder.mixin(tracker.class.Issue, core.class.Class, setting.mixin.Editable, {})

builder.mixin(tracker.class.TypeProjectStatus, core.class.Class, view.mixin.AttributeEditor, {
editor: tracker.component.ProjectStatusEditor
inlineEditor: tracker.component.ProjectStatusEditor
})

builder.mixin(tracker.class.Issue, core.class.Class, notification.mixin.LastViewAttached, {})
Expand Down
7 changes: 4 additions & 3 deletions models/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function classPresenter (
})
if (editor !== undefined) {
builder.mixin(_class, core.class.Class, view.mixin.AttributeEditor, {
editor,
inlineEditor: editor,
popup
})
}
Expand All @@ -102,7 +102,7 @@ export class TAttributeFilter extends TClass implements AttributeFilter {

@Mixin(view.mixin.AttributeEditor, core.class.Class)
export class TAttributeEditor extends TClass implements AttributeEditor {
editor!: AnyComponent
inlineEditor!: AnyComponent
}

@Mixin(view.mixin.CollectionPresenter, core.class.Class)
Expand All @@ -113,11 +113,12 @@ export class TCollectionPresenter extends TClass implements CollectionPresenter
@Mixin(view.mixin.CollectionEditor, core.class.Class)
export class TCollectionEditor extends TClass implements CollectionEditor {
editor!: AnyComponent
inlineEditor?: AnyComponent
}

@Mixin(view.mixin.ArrayEditor, core.class.Class)
export class TArrayEditor extends TClass implements ArrayEditor {
editor!: AnyComponent
inlineEditor!: AnyComponent
}

@Mixin(view.mixin.AttributePresenter, core.class.Class)
Expand Down
15 changes: 8 additions & 7 deletions packages/presentation/src/components/AttributeBarEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@
}
const category = presenterClass.category
let mixinRef = view.mixin.AttributeEditor
if (category === 'collection') {
mixinRef = view.mixin.CollectionEditor
}
if (category === 'array') {
mixinRef = view.mixin.ArrayEditor
}

if (mixinRef !== undefined) {
const typeClass = hierarchy.getClass(presenterClass.attrClass)
const editorMixin = hierarchy.as(typeClass, mixinRef)
editor = getResource(editorMixin.editor).catch((cause) => {
console.error(`failed to find editor for ${_class} ${attribute} ${presenterClass.attrClass} cause: ${cause}`)
})
}
const typeClass = hierarchy.getClass(presenterClass.attrClass)
const editorMixin = hierarchy.as(typeClass, mixinRef)
editor = getResource(editorMixin.inlineEditor).catch((cause) => {
console.error(`failed to find editor for ${_class} ${attribute} ${presenterClass.attrClass} cause: ${cause}`)
})
}
$: update(attribute, presenterClass)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$: if (presenterClass !== undefined) {
const typeClass = hierarchy.getClass(presenterClass.attrClass)
const editorMixin = hierarchy.as(typeClass, view.mixin.AttributeEditor)
editor = getResource(editorMixin.editor)
editor = getResource(editorMixin.inlineEditor)
}

function onChange (value: any) {
Expand Down
5 changes: 3 additions & 2 deletions plugins/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface AttributeFilter extends Class<Type<any>> {
* @public
*/
export interface AttributeEditor extends Class<Doc> {
editor: AnyComponent
inlineEditor: AnyComponent
// If defined could be used for ShowEditor declarative actions.
popup?: AnyComponent
}
Expand All @@ -92,13 +92,14 @@ export interface AttributeEditor extends Class<Doc> {
*/
export interface CollectionEditor extends Class<Doc> {
editor: AnyComponent
inlineEditor?: AnyComponent
}

/**
* @public
*/
export interface ArrayEditor extends Class<Doc> {
editor: AnyComponent
inlineEditor: AnyComponent
}

/**
Expand Down