2021-08-07 14:49:14 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
2021-12-02 13:12:16 +00:00
|
|
|
//
|
2021-08-07 14:49:14 +00:00
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
2021-12-02 13:12:16 +00:00
|
|
|
//
|
2021-08-07 14:49:14 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2021-12-02 13:12:16 +00:00
|
|
|
//
|
2021-08-07 14:49:14 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
2021-11-25 11:07:44 +00:00
|
|
|
import type { AttachedDoc, Doc } from '@anticrm/core'
|
|
|
|
import core from '@anticrm/core'
|
2021-12-02 13:12:16 +00:00
|
|
|
import { Resources } from '@anticrm/platform'
|
|
|
|
import { getClient, MessageBox } from '@anticrm/presentation'
|
|
|
|
import { showPopup } from '@anticrm/ui'
|
2021-10-04 19:18:23 +00:00
|
|
|
import BooleanEditor from './components/BooleanEditor.svelte'
|
2021-11-22 10:55:52 +00:00
|
|
|
import BooleanPresenter from './components/BooleanPresenter.svelte'
|
2021-12-02 09:09:37 +00:00
|
|
|
import DateEditor from './components/DateEditor.svelte'
|
|
|
|
import DatePresenter from './components/DatePresenter.svelte'
|
2021-09-06 08:40:20 +00:00
|
|
|
import KanbanView from './components/KanbanView.svelte'
|
2021-12-02 13:12:16 +00:00
|
|
|
import StateEditor from './components/StateEditor.svelte'
|
|
|
|
import StatePresenter from './components/StatePresenter.svelte'
|
|
|
|
import StringEditor from './components/StringEditor.svelte'
|
|
|
|
import StringPresenter from './components/StringPresenter.svelte'
|
|
|
|
import Table from './components/Table.svelte'
|
|
|
|
import TableView from './components/TableView.svelte'
|
|
|
|
import TimestampPresenter from './components/TimestampPresenter.svelte'
|
2021-08-07 14:49:14 +00:00
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
export { default as ContextMenu } from './components/Menu.svelte'
|
|
|
|
export { buildModel, getActions, getObjectPresenter } from './utils'
|
2021-10-23 14:49:11 +00:00
|
|
|
export { Table }
|
2021-10-13 08:38:35 +00:00
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
function Delete (object: Doc): void {
|
2021-10-13 09:06:35 +00:00
|
|
|
showPopup(MessageBox, {
|
|
|
|
label: 'Delete object',
|
|
|
|
message: 'Do you want to delete this object?'
|
|
|
|
}, undefined, (result) => {
|
2021-12-02 13:12:16 +00:00
|
|
|
if (result !== undefined) {
|
2021-10-13 09:06:35 +00:00
|
|
|
const client = getClient()
|
2021-12-02 13:12:16 +00:00
|
|
|
if (client.getHierarchy().isDerived(object._class, core.class.AttachedDoc)) {
|
2021-11-25 11:07:44 +00:00
|
|
|
const adoc = object as AttachedDoc
|
2021-12-02 13:12:16 +00:00
|
|
|
client.removeCollection(object._class, object.space, adoc._id, adoc.attachedTo, adoc.attachedToClass, adoc.collection).catch(err => console.error(err))
|
2021-11-25 11:07:44 +00:00
|
|
|
} else {
|
2021-12-02 13:12:16 +00:00
|
|
|
client.removeDoc(object._class, object.space, object._id).catch(err => console.error(err))
|
2021-11-25 11:07:44 +00:00
|
|
|
}
|
2021-10-13 09:06:35 +00:00
|
|
|
}
|
|
|
|
})
|
2021-09-25 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
export default async (): Promise<Resources> => ({
|
2021-09-25 16:48:22 +00:00
|
|
|
actionImpl: {
|
|
|
|
Delete
|
|
|
|
},
|
2021-08-07 14:49:14 +00:00
|
|
|
component: {
|
|
|
|
StringEditor,
|
|
|
|
StringPresenter,
|
2021-11-22 10:55:52 +00:00
|
|
|
BooleanPresenter,
|
2021-10-04 19:18:23 +00:00
|
|
|
BooleanEditor,
|
2021-09-05 12:03:33 +00:00
|
|
|
StatePresenter,
|
2021-11-29 11:32:17 +00:00
|
|
|
StateEditor,
|
2021-09-06 08:40:20 +00:00
|
|
|
TableView,
|
2021-10-05 14:34:52 +00:00
|
|
|
KanbanView,
|
2021-12-02 09:09:37 +00:00
|
|
|
TimestampPresenter,
|
|
|
|
DateEditor,
|
|
|
|
DatePresenter
|
2021-11-18 12:48:05 +00:00
|
|
|
}
|
2021-08-07 14:49:14 +00:00
|
|
|
})
|