UNPKG

waibu-db

Version:
25 lines (21 loc) 908 B
import wdbBase from '../wdb-base.js' async function btnAdd () { const WdbBase = await wdbBase.call(this) return class WdbBtnAdd extends WdbBase { build = async () => { const { isEmpty } = this.app.lib._ const { req } = this.component this.params.noTag = true const allowed = await this.isActionAllowed('CREATE') if (!allowed || this.schema.view.disabled.includes('create')) { this.params.html = '' return } if (isEmpty(this.params.attr.content)) this.params.attr.content = req.t('add') this.params.attr.color = this.params.attr.color ?? 'secondary-outline' if (!this.params.attr.href) this.params.attr.href = this.component.buildUrl({ base: 'add' }) this.params.html = await this.component.buildTag({ tag: 'btn', attr: this.params.attr, html: this.params.html }) } } } export default btnAdd