Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color for the columns #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion amd/build/column.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/column.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/exporter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/exporter.min.js.map

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions amd/src/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,21 @@ export default class extends KanbanComponent {
this.getElement(selectors.INPLACEEDITABLE).setAttribute('data-value', doc.documentElement.textContent);
this.getElement(selectors.INPLACEEDITABLE).querySelector('a').innerHTML = element.title;
}
// Only autohide option is relevant for the frontend for now. autoclose option is handled by the backend.
// Only autohide and backgroundcolor option is relevant for the frontend for now.
// Autoclose option is handled by the backend.
if (element.options !== undefined) {
let options = JSON.parse(element.options);
this.toggleClass(options.autohide, 'mod_kanban_autohide');
if (options.autohide === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary as toggleClass() already handles undefined values.

this.toggleClass(false, 'mod_kanban_autohide');
} else {
this.toggleClass(true, 'mod_kanban_autohide');
}

if (options.colbackground === undefined) {
this.getElement().removeAttribute('style');
} else {
this.getElement().setAttribute('style', 'background-color: ' + options.colbackground);
}
}
// Enable/disable dragging (e.g. if column is locked).
this.checkDragging();
Expand Down
1 change: 1 addition & 0 deletions amd/src/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class {
col.hascards = col.sequence != '';
col.autoclose = options.autoclose;
col.autohide = options.autohide;
col.colbackground = options.colbackground;
if (col.hascards) {
let cardOrder = col.sequence.split(',');
col.cards = cardOrder.map((value) => {
Expand Down
10 changes: 9 additions & 1 deletion classes/boardmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,16 @@ public function update_column(int $columnid, array $data): void {
$column = $this->get_column($columnid);
$options = [
'autoclose' => $data['autoclose'],
'autohide' => $data['autohide'],
];

if (!empty($data['autohide'])) {
$options['autohide'] = $data['autohide'];
}

if (!empty($data['color'])) {
$options['colbackground'] = $data['color'];
}

if (isset($data['title'])) {
$data['title'] = s($data['title']);
}
Expand Down
5 changes: 5 additions & 0 deletions classes/form/edit_column_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function definition() {

$mform->addElement('advcheckbox', 'autohide', get_string('autohide', 'kanban'));
$mform->setType('autohide', PARAM_BOOL);

$mform->addElement('color', 'color', get_string('color', 'mod_kanban'), ['size' => 5]);
$mform->setType('color', PARAM_TEXT);
$mform->setDefault('color', '#ffffff');
}

/**
Expand Down Expand Up @@ -124,6 +128,7 @@ public function set_data_for_dynamic_submission(): void {
$options = json_decode($column->options);
$column->autoclose = $options->autoclose;
$column->autohide = $options->autohide;
$column->color = $options->colbackground;
$this->set_data($column);
}

Expand Down
2 changes: 1 addition & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ a.mod_kanban_attachment_item {
}

.mod_kanban_board .btn {
background-color: white;
background-color: transparent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change?

}

.mod_kanban_column_container.row {
Expand Down
5 changes: 3 additions & 2 deletions templates/column.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
"managecolumns": true,
"hascards": false,
"autohide": true,
"locked": false
"locked": false,
"colbackground": "#AAAAFF"
}
}}
<li class="mod_kanban_column col card{{#autohide}} mod_kanban_autohide{{/autohide}} {{#locked}}mod_kanban_locked_column{{/locked}}" id="mod_kanban_column-{{id}}" data-id="{{id}}">
<li style="{{#colbackground}}background-color: {{colbackground}}{{/colbackground}}" class="mod_kanban_column col card{{#autohide}} mod_kanban_autohide{{/autohide}} {{#locked}}mod_kanban_locked_column{{/locked}}" id="mod_kanban_column-{{id}}" data-id="{{id}}">
<h5 class="mod_kanban_column_title card-title">
<span class="inplaceeditable inplaceeditable-text"{{#managecolumns}} {{^locked}}data-inplaceeditable="1" {{/locked}}data-component="mod_kanban" data-itemtype="column" data-itemid="{{id}}"
data-value="{{{title}}}" data-type="text"{{/managecolumns}}>
Expand Down
Loading