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

Feature/fix phperror missing parameter #59

Open
wants to merge 2 commits 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) {
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
16 changes: 14 additions & 2 deletions classes/boardmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,11 @@ public function update_card(int $cardid, array $data): void {
}
$cardupdate['attachments'] = helper::get_attachments($context->id, $cardid);
$cardupdate['hasattachment'] = count($cardupdate['attachments']) > 0;
$cardupdate['hasdescription'] = !empty(trim($cardupdate['description'])) || $cardupdate['hasattachment'];
$trimdescription = null;
if (!empty($cardupdate['description'])){
$trimdescription = trim($cardupdate['description']);
}
$cardupdate['hasdescription'] = !empty($trimdescription) || $cardupdate['hasattachment'];
if (!empty($cardupdate['description'])) {
$cardupdate['description'] = file_rewrite_pluginfile_urls(
$cardupdate['description'],
Expand Down Expand Up @@ -943,8 +947,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
6 changes: 4 additions & 2 deletions classes/form/edit_card_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,14 @@ public function set_data_for_dynamic_submission(): void {
$context = $this->get_context_for_dynamic_submission();
$id = $this->optional_param('id', null, PARAM_INT);
$card = $DB->get_record('kanban_card', ['id' => $id]);
$options = json_decode($card->options);
$card->title = html_entity_decode($card->title, ENT_COMPAT, 'UTF-8');
$card->cmid = $this->optional_param('cmid', null, PARAM_INT);
$card->boardid = $card->kanban_board;
$card->assignees = $DB->get_fieldset_select('kanban_assignee', 'userid', 'kanban_card = :cardid', ['cardid' => $id]);
$card->color = $options->background;
$options = json_decode($card->options);
if (property_exists($options, 'background')){
$card->color = $options->background;
}
$draftitemid = file_get_submitted_draft_itemid('attachments');
$card->description = file_prepare_draft_area(
$draftitemid,
Expand Down
19 changes: 16 additions & 3 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 @@ -121,9 +125,18 @@ public function set_data_for_dynamic_submission(): void {
$column->cmid = $this->optional_param('cmid', null, PARAM_INT);
$column->title = html_entity_decode($column->title, ENT_COMPAT, 'UTF-8');
$column->boardid = $column->kanban_board;
$options = json_decode($column->options);
$column->autoclose = $options->autoclose;
$column->autohide = $options->autohide;
if (!empty($column->options)){
$options = json_decode($column->options);
if (property_exists($options, 'autoclose')){
$column->autoclose = $options->autoclose;
}
if (property_exists($options, 'autohide')){
$column->autohide = $options->autohide;
}
if (property_exists($options, 'colbackground')){
$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;
}

.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