mirror of
https://github.com/discourse/discourse-table-builder.git
synced 2026-09-16 23:02:13 -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,34 @@
|
||||
import GlimmerComponent from "discourse/components/glimmer";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default class BodyRow extends GlimmerComponent {
|
||||
get disableRemoveRow() {
|
||||
if (this.args.allRows.length > 1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
addBodyValue() {
|
||||
const columnId = this.args.columnId;
|
||||
const rowId = this.args.row.id;
|
||||
const value = this.bodyRowValue;
|
||||
|
||||
this.args.setRowValue(columnId, rowId, value);
|
||||
}
|
||||
|
||||
@action
|
||||
addRow() {
|
||||
const columnId = this.args.columnId;
|
||||
const rowId = this.args.allRows.length + 1;
|
||||
|
||||
this.args.addRow(columnId, rowId);
|
||||
}
|
||||
|
||||
@action
|
||||
removeRow() {
|
||||
this.args.removeRow(this.args.columnId, this.args.row);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import GlimmerComponent from "discourse/components/glimmer";
|
||||
import { action } from "@ember/object";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
|
||||
export default class HeaderColumn extends GlimmerComponent {
|
||||
@tracked alignment;
|
||||
|
||||
get disableRemoveColumn() {
|
||||
if (this.args.tableItems.length > 1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
addColumn() {
|
||||
const newColumnId = this.args.tableItems.length + 1;
|
||||
this.args.addColumn(newColumnId);
|
||||
}
|
||||
|
||||
@action
|
||||
removeColumn() {
|
||||
this.args.removeColumn(this.args.column);
|
||||
}
|
||||
|
||||
@action
|
||||
addColumnHeader() {
|
||||
const index = this.args.columnId - 1;
|
||||
this.args.setColumnHeader(index, this.columnHeaderValue);
|
||||
}
|
||||
|
||||
@action
|
||||
addRow(columnId, rowId) {
|
||||
this.args.addRow(columnId, rowId);
|
||||
}
|
||||
|
||||
@action
|
||||
removeRow(columnId, row) {
|
||||
this.args.removeRow(columnId, row);
|
||||
}
|
||||
|
||||
@action
|
||||
setRowValue(columnId, rowId, value) {
|
||||
this.args.setRowValue(columnId, rowId, value);
|
||||
}
|
||||
|
||||
@action
|
||||
alignColumn(alignment) {
|
||||
this.args.alignColumn(this.args.columnId, alignment);
|
||||
this.alignment = alignment;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user