Tags: Add inline editor (#2081)

Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
Anna No 2022-06-16 00:25:58 +07:00 committed by GitHub
parent 5a28f6294f
commit e732568c2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 26 deletions

View File

@ -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(

View File

@ -223,7 +223,7 @@ 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, {
@ -231,7 +231,7 @@ export function createModel (builder: Builder): void {
})
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, {
@ -239,11 +239,11 @@ export function createModel (builder: Builder): void {
})
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, {

View File

@ -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, {

View File

@ -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, {
@ -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, {

View File

@ -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, {})

View File

@ -78,7 +78,7 @@ export function classPresenter (
})
if (editor !== undefined) {
builder.mixin(_class, core.class.Class, view.mixin.AttributeEditor, {
editor,
inlineEditor: editor,
popup
})
}
@ -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)
@ -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)

View File

@ -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)

View File

@ -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) {

View File

@ -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
}
@ -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
}
/**