2020-10-20 21:50:53 +02:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
2020-11-10 20:23:08 +01:00
|
|
|
import {Utils} from '../utils'
|
2020-10-21 03:58:48 +02:00
|
|
|
import {IBlock} from '../blocks/block'
|
2020-10-15 02:35:15 +02:00
|
|
|
|
2020-10-21 03:28:55 +02:00
|
|
|
import {MutableBlock} from './block'
|
|
|
|
|
|
|
|
interface Card extends IBlock {
|
|
|
|
readonly icon: string
|
2020-11-10 20:23:08 +01:00
|
|
|
readonly isTemplate: boolean
|
2020-10-21 03:28:55 +02:00
|
|
|
readonly properties: Readonly<Record<string, string>>
|
2020-11-10 20:23:08 +01:00
|
|
|
newCardFromTemplate(): MutableCard
|
2020-10-21 03:28:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class MutableCard extends MutableBlock {
|
2020-10-20 21:50:53 +02:00
|
|
|
get icon(): string {
|
|
|
|
return this.fields.icon as string
|
|
|
|
}
|
|
|
|
set icon(value: string) {
|
|
|
|
this.fields.icon = value
|
|
|
|
}
|
2020-10-15 02:35:15 +02:00
|
|
|
|
2020-11-10 20:23:08 +01:00
|
|
|
get isTemplate(): boolean {
|
|
|
|
return this.fields.isTemplate as boolean
|
|
|
|
}
|
|
|
|
set isTemplate(value: boolean) {
|
|
|
|
this.fields.isTemplate = value
|
|
|
|
}
|
|
|
|
|
2020-10-20 21:50:53 +02:00
|
|
|
get properties(): Record<string, string> {
|
|
|
|
return this.fields.properties as Record<string, string>
|
|
|
|
}
|
|
|
|
set properties(value: Record<string, string>) {
|
|
|
|
this.fields.properties = value
|
|
|
|
}
|
2020-10-15 02:35:15 +02:00
|
|
|
|
2020-10-20 21:50:53 +02:00
|
|
|
constructor(block: any = {}) {
|
|
|
|
super(block)
|
2020-10-20 21:52:56 +02:00
|
|
|
this.type = 'card'
|
2020-10-15 02:35:15 +02:00
|
|
|
|
2020-10-20 21:50:53 +02:00
|
|
|
this.properties = {...(block.fields?.properties || {})}
|
|
|
|
}
|
2020-11-10 20:23:08 +01:00
|
|
|
|
|
|
|
newCardFromTemplate(): MutableCard {
|
|
|
|
const card = new MutableCard(this)
|
|
|
|
card.id = Utils.createGuid()
|
|
|
|
card.isTemplate = false
|
|
|
|
card.title = ''
|
|
|
|
return card
|
|
|
|
}
|
2020-10-15 02:35:15 +02:00
|
|
|
}
|
|
|
|
|
2020-10-21 03:28:55 +02:00
|
|
|
export {MutableCard, Card}
|