Skip to content

Commit

Permalink
feat(form): set background color of tile
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Aug 22, 2019
1 parent 5149235 commit d6e40a2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ form.formcreator_form {
cursor: pointer;
border-radius: 0;
box-sizing: border-box;
background-color: #E7E7E7;
//background-color: #E7E7E7;
animation-name: fadeInUp ;
animation-iteration-count: 1;
animation-timing-function: ease-in;
Expand Down
11 changes: 7 additions & 4 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,11 @@ public function showForm($ID, $options = []) {
echo '<td>' . __('Form icon', 'formcreator') . '</td>';
echo '<td>';
PluginFormcreatorCommon::showFontAwesomeDropdown('icon', ['value' => $this->fields['icon']]);
Html::showColorField('icon_color', ['value' => $this->fields['icon_color']]);
echo '</td>';
echo '<td>' . __('Icon color', 'formcreator') . '</td>';
echo '<td>' . __('Background color', 'formcreator') . '</td>';
echo '<td>';
Html::showColorField('icon_color', ['value' => $this->fields['icon_color']]);
Html::showColorField('background_color', ['value' => $this->fields['background_color']]);
echo '</td>';
echo '</tr>';

Expand Down Expand Up @@ -829,7 +830,7 @@ public function showFormList($rootCategory = 0, $keywords = '', $helpdeskHome =

$result_forms = $DB->request([
'SELECT' => [
$table_form => ['id', 'name', 'icon', 'icon_color', 'description', 'usage_count', 'is_default'],
$table_form => ['id', 'name', 'icon', 'icon_color', 'background_color', 'description', 'usage_count', 'is_default'],
],
'FROM' => $table_form,
'LEFT JOIN' => [
Expand Down Expand Up @@ -879,6 +880,7 @@ public function showFormList($rootCategory = 0, $keywords = '', $helpdeskHome =
'name' => $form['name'],
'icon' => $form['icon'],
'icon_color' => $form['icon_color'],
'background_color' => $form['background_color'],
'description' => $form['description'],
'type' => 'form',
'usage_count' => $form['usage_count'],
Expand Down Expand Up @@ -962,7 +964,7 @@ public function showFormList($rootCategory = 0, $keywords = '', $helpdeskHome =

$query_forms = [
'SELECT' => [
$table_form => ['id', 'name', 'icon', 'description', 'usage_count'],
$table_form => ['id', 'name', 'icon', 'icon_color', 'background_color', 'description', 'usage_count'],
],
'FROM' => $table_form,
'LEFT JOIN' => [
Expand All @@ -987,6 +989,7 @@ public function showFormList($rootCategory = 0, $keywords = '', $helpdeskHome =
'name' => $form['name'],
'icon' => $form['icon'],
'icon_color' => $form['icon_color'],
'background_color' => $form['background_color'],
'description' => $form['description'],
'type' => 'form',
'usage_count' => $form['usage_count'],
Expand Down
1 change: 1 addition & 0 deletions install/mysql/plugin_formcreator_empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms` (
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
`icon` varchar(255) NOT NULL DEFAULT '',
`icon_color` varchar(255) NOT NULL DEFAULT '',
`background_color` varchar(255) NOT NULL DEFAULT '',
`access_rights` tinyint(1) NOT NULL DEFAULT '1',
`requesttype` int(11) NOT NULL DEFAULT '0',
`description` varchar(255) DEFAULT NULL,
Expand Down
1 change: 1 addition & 0 deletions install/upgrade_to_2.9.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public function upgrade(Migration $migration) {
$table = 'glpi_plugin_formcreator_forms';
$migration->addField($table, 'icon', 'string', ['after' => 'is_recursive']);
$migration->addField($table, 'icon_color', 'string', ['after' => 'icon']);
$migration->addField($table, 'background_color', 'string', ['after' => 'icon']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions js/scripts.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function buildTiles(list) {

if (item.type == 'form') {
forms.push(
'<div class="plugin_formcreator_formTile '+item.type+' '+default_class+'" title="'+item.description+'">'
'<div style="background-color: ' + item.background_color + '" class="plugin_formcreator_formTile '+item.type+' '+default_class+'" title="'+item.description+'">'
+ '<i class="fa ' + item.icon + '" style="color: ' + item.icon_color+ '"></i>'
+ '<a href="' + url + '" class="plugin_formcreator_formTile_title">'
+ item.name
Expand All @@ -416,7 +416,7 @@ function buildTiles(list) {
);
} else {
faqs.push(
'<div class="plugin_formcreator_formTile '+item.type+' '+default_class+'" title="'+item.description+'">'
'<div style="background-color: ' + item.background_color + '" class="plugin_formcreator_formTile '+item.type+' '+default_class+'" title="'+item.description+'">'
+ '<i class="fa ' + item.icon + '" style="color: ' + item.icon_color+ '"></i>'
+ '<a href="' + url + '" class="plugin_formcreator_formTile_title">'
+ item.name
Expand Down
1 change: 1 addition & 0 deletions tests/suite-unit/PluginFormcreatorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ public function testExport() {
'is_recursive',
'icon',
'icon_color',
'background_color',
'access_rights',
'requesttype',
'description',
Expand Down

0 comments on commit d6e40a2

Please sign in to comment.