mirror of
https://github.com/discourse/discourse-table-builder.git
synced 2026-09-30 20:43:56 -04:00
FEATURE: Ability to build a table in the composer
- Adds a button to the composer tools which triggers a modal window for a table builder - Table builder contains fields to add table contents, as well as buttons to align contents, and add additional tables/rows
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<div class="body-row">
|
||||
<Input
|
||||
@value={{bodyRowValue}}
|
||||
@class="table-builder-input"
|
||||
@placeholderKey={{theme-prefix "discourse_table_builder.modal.body"}}
|
||||
{{on "change" this.addBodyValue}}
|
||||
/>
|
||||
<DButton
|
||||
@icon="plus"
|
||||
@title={{theme-prefix "discourse_table_builder.modal.buttons.add_row"}}
|
||||
@action={{action "addRow"}}
|
||||
/>
|
||||
<DButton
|
||||
@icon="trash-alt"
|
||||
@class="btn-danger"
|
||||
@title={{theme-prefix "discourse_table_builder.modal.buttons.remove_row"}}
|
||||
@action={{action "removeRow"}}
|
||||
@disabled={{this.disableRemoveRow}}
|
||||
/>
|
||||
</div>
|
||||
@@ -0,0 +1,62 @@
|
||||
<div class="header-column">
|
||||
<div class="header-row">
|
||||
<Input
|
||||
@value={{columnHeaderValue}}
|
||||
@class="table-builder-input"
|
||||
@id="header-column-{{@columnId}}"
|
||||
@placeholderKey={{theme-prefix "discourse_table_builder.modal.header"}}
|
||||
{{on "change" this.addColumnHeader}}
|
||||
/>
|
||||
<div class="body-inputs">
|
||||
{{#each @column.rows as |item|}}
|
||||
<BodyRow
|
||||
@addRow={{this.addRow}}
|
||||
@columnId={{@columnId}}
|
||||
@allRows={{@column.rows}}
|
||||
@row={{item}}
|
||||
@removeRow={{this.removeRow}}
|
||||
@setRowValue={{this.setRowValue}}
|
||||
/>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="column-action-buttons column-aligned-{{this.alignment}}">
|
||||
<DButton
|
||||
@icon="align-left"
|
||||
@class="btn-align-left"
|
||||
@title={{theme-prefix "discourse_table_builder.modal.buttons.align_left"}}
|
||||
@action={{action "alignColumn" "left"}}
|
||||
/>
|
||||
<DButton
|
||||
@icon="align-center"
|
||||
@class="btn-align-center"
|
||||
@title={{theme-prefix
|
||||
"discourse_table_builder.modal.buttons.align_center"
|
||||
}}
|
||||
@action={{action "alignColumn" "center"}}
|
||||
/>
|
||||
<DButton
|
||||
@icon="align-right"
|
||||
@class="btn-align-right"
|
||||
@title={{theme-prefix
|
||||
"discourse_table_builder.modal.buttons.align_right"
|
||||
}}
|
||||
@action={{action "alignColumn" "right"}}
|
||||
/>
|
||||
<DButton
|
||||
@icon="trash-alt"
|
||||
@class="btn-danger"
|
||||
@action={{action "removeColumn"}}
|
||||
@title={{theme-prefix
|
||||
"discourse_table_builder.modal.buttons.remove_column"
|
||||
}}
|
||||
@disabled={{this.disableRemoveColumn}}
|
||||
/>
|
||||
<DButton
|
||||
@icon="plus"
|
||||
@action={{action "addColumn"}}
|
||||
@title={{theme-prefix "discourse_table_builder.modal.buttons.add_column"}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,40 @@
|
||||
<DModalBody
|
||||
@title={{theme-prefix "discourse_table_builder.modal.title"}}
|
||||
@class="table-builder-modal"
|
||||
>
|
||||
<form id="insert-markdown-table-form" {{action "createTable" on="submit"}}>
|
||||
<section class="header-section">
|
||||
<div class="table-header-fields">
|
||||
{{#each this.tableItems as |item|}}
|
||||
<HeaderColumn
|
||||
@column={{item}}
|
||||
@columnId={{item.column}}
|
||||
@tableItems={{this.tableItems}}
|
||||
@addColumn={{this.addColumn}}
|
||||
@removeColumn={{this.removeColumn}}
|
||||
@setColumnHeader={{this.setColumnHeader}}
|
||||
@addRow={{this.addRow}}
|
||||
@removeRow={{this.removeRow}}
|
||||
@setRowValue={{this.setRowValue}}
|
||||
@alignColumn={{this.alignColumn}}
|
||||
/>
|
||||
{{/each}}
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
</DModalBody>
|
||||
|
||||
<div class="modal-footer">
|
||||
<DButton
|
||||
@class="btn-primary"
|
||||
@label={{theme-prefix "discourse_table_builder.modal.create"}}
|
||||
@icon="plus"
|
||||
@action={{action "createTable"}}
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@class="btn-flat"
|
||||
@label={{theme-prefix "discourse_table_builder.modal.cancel"}}
|
||||
@action={{action "cancelTableCreation"}}
|
||||
/>
|
||||
</div>
|
||||
Reference in New Issue
Block a user