color & color text fields instead of badge classes

This commit is contained in:
Ulf Gebhardt 2019-09-03 11:12:19 +02:00
parent 791a7c789e
commit 559a114e05
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
12 changed files with 38 additions and 81 deletions

View File

@ -182,10 +182,11 @@ function init_saimod_person_details(){
});
// Badge Preview Color
$('.input-badge-color, #input-ability-color').change(function(){
$(this).parent().parent().find('.badge').removeClass(function (index, className) {
return (className.match (/(^|\s)badge-\S+/g) || []).join(' ');
});
$(this).parent().parent().find('.badge').addClass($(this).val());
$(this).parent().parent().find('.badge').css('background-color','#'+$(this).val());
});
// Badge Preview Color text
$('.input-badge-color-text, #input-ability-color-text').change(function(){
$(this).parent().parent().find('.badge').css('color','#'+$(this).val());
});
// Ability New Button
@ -193,6 +194,7 @@ function init_saimod_person_details(){
person = $(this).attr('person');
badge = $('#input-ability-badge').val();
color = $('#input-ability-color').val();
color_text = $('#input-ability-color-text').val();
visibility = $('#input-ability-visibility').val();
$.ajax({
async: true,
@ -206,6 +208,7 @@ function init_saimod_person_details(){
person: person,
badge: badge,
color: color,
color_text: color_text,
visibility: visibility
}
},

View File

@ -115,13 +115,9 @@ class saimod_person extends \SYSTEM\SAI\sai_module{
$row['selected_invisible'] = $row['visible'] !== 1 ? 'selected' : '';
$row['selected_visible'] = $row['visible'] == 1 ? 'selected' : '';
$row['badge_colors'] = self::badge_color_options($row['color']);
$vars['abilities'] .= \SYSTEM\PAGE\replace::replaceFile((new \SAI\PPERSON('tpl/saimod_person_badge_tr.tpl'))->SERVERPATH(),$row);
}
$vars['badge_colors'] = self::badge_color_options();
return \SYSTEM\PAGE\replace::replaceFile((new \SAI\PPERSON('tpl/saimod_person_details.tpl'))->SERVERPATH(),$vars);
}
@ -141,6 +137,7 @@ class saimod_person extends \SYSTEM\SAI\sai_module{
$data['person'],
$data['badge'],
$data['color'],
$data['color_text'],
\SAI\saimod_project::BADGE_TYPE_PERSON_ABILITIES,
$data['person'],
$data['visibility']))
@ -179,25 +176,6 @@ class saimod_person extends \SYSTEM\SAI\sai_module{
return \JsonResult::ok();
}
private static function badge_color_options($selected = null){
$colors = array(
'badge-primary',
'badge-secondary',
'badge-success',
'badge-danger',
'badge-warning',
'badge-info',
'badge-light',
'badge-dark'
);
$result = '';
foreach($colors as $color){
$vars = array('value' => $color, 'selected' => $color == $selected ? 'selected' : '');
$result .= \SYSTEM\PAGE\replace::replaceFile((new \SAI\PPERSON('tpl/badge_color_option.tpl'))->SERVERPATH(),$vars);
}
return $result;
}
public static function menu(){
return new \SYSTEM\SAI\sai_module_menu( 102,
\SYSTEM\SAI\sai_module_menu::POISITION_LEFT,

View File

@ -1 +1 @@
<span class="badge ${color}">${badge}</span>
<span class="badge" style="background-color: #${color}; color: #${color_text};">${badge}</span>

View File

@ -1,7 +1,8 @@
<tr>
<td><span class="badge ${color}">${badge}</span></td>
<td><span class="badge" style="background-color: #${color}; color: #${color_text}">${badge}</span></td>
<td>${badge}</td>
<td>${color}</td>
<td>${color_text}</td>
<td style="font-size: 30px">
<a href="#" class="badge-order-up" badge="${id}" type="${type}" ref_id="${ref_id}" order="${order}"><i class="fa fa-caret-up"></i></a>
<a href="#" class="badge-order-down" badge="${id}" type="${type}" ref_id="${ref_id}" order="${order}" order="${order}"><i class="fa fa-caret-down"></i></a>

View File

@ -49,6 +49,7 @@
<th>Preview</th>
<th>Badge</th>
<th>Color</th>
<th>Text Color</th>
<th>Order</th>
<th>Visible</th>
<th>
@ -59,13 +60,10 @@
<tbody>
${abilities}
<tr>
<td><span class="badge badge-primary"></span></td>
<td><span class="badge"></span></td>
<td><input id="input-ability-badge" class="form-control" type="text" style="width: 100%"/></td>
<td>
<select id="input-ability-color" class="form-control">
${badge_colors}
</select>
</td>
<td><input id="input-ability-color" class="form-control" type="text" minlength="6" maxlength="6" style="width: 100%"/></td>
<td><input id="input-ability-color-text" class="form-control" type="text" minlength="6" maxlength="6" style="width: 100%"/></td>
<td></td>
<td>
<select id="input-ability-visibility" class="form-control">

View File

@ -184,10 +184,11 @@ function init_saimod_project_details(){
});
// Badge Preview Color
$('.input-badge-color, #input-focus-color, #input-type-color').change(function(){
$(this).parent().parent().find('.badge').removeClass(function (index, className) {
return (className.match (/(^|\s)badge-\S+/g) || []).join(' ');
});
$(this).parent().parent().find('.badge').addClass($(this).val());
$(this).parent().parent().find('.badge').css('background-color','#'+$(this).val());
});
// Badge Preview Color text
$('.input-badge-color-text, #input-focus-color-text, #input-type-color-text').change(function(){
$(this).parent().parent().find('.badge').css('color','#'+$(this).val());
});
// Focus New Button
@ -195,6 +196,7 @@ function init_saimod_project_details(){
project = $(this).attr('project');
badge = $('#input-focus-badge').val();
color = $('#input-focus-color').val();
color_text = $('#input-focus-color-text').val();
visibility = $('#input-focus-visibility').val();
$.ajax({
async: true,
@ -208,6 +210,7 @@ function init_saimod_project_details(){
project: project,
badge: badge,
color: color,
color_text: color_text,
visibility: visibility
}
},
@ -229,6 +232,7 @@ function init_saimod_project_details(){
project = $(this).attr('project');
badge = $('#input-type-badge').val();
color = $('#input-type-color').val();
color_text = $('#input-type-color-text').val();
visibility = $('#input-type-visibility').val();
$.ajax({
async: true,
@ -242,6 +246,7 @@ function init_saimod_project_details(){
project: project,
badge: badge,
color: color,
color_text: color_text,
visibility: visibility
}
},

View File

@ -128,8 +128,6 @@ class saimod_project extends \SYSTEM\SAI\sai_module{
$row['selected_invisible'] = $row['visible'] !== 1 ? 'selected' : '';
$row['selected_visible'] = $row['visible'] == 1 ? 'selected' : '';
$row['badge_colors'] = self::badge_color_options($row['color']);
$vars['focus'] .= \SYSTEM\PAGE\replace::replaceFile((new \SAI\PPROJECT('tpl/saimod_project_badge_tr.tpl'))->SERVERPATH(),$row);
}
@ -139,14 +137,10 @@ class saimod_project extends \SYSTEM\SAI\sai_module{
while($row = $type->next()){
$row['selected_invisible'] = $row['visible'] !== 1 ? 'selected' : '';
$row['selected_visible'] = $row['visible'] == 1 ? 'selected' : '';
$row['badge_colors'] = self::badge_color_options($row['color']);
$vars['type'] .= \SYSTEM\PAGE\replace::replaceFile((new \SAI\PPROJECT('tpl/saimod_project_badge_tr.tpl'))->SERVERPATH(),$row);
}
$vars['badge_colors'] = self::badge_color_options();
return \SYSTEM\PAGE\replace::replaceFile((new \SAI\PPROJECT('tpl/saimod_project_details.tpl'))->SERVERPATH(),$vars);
}
@ -167,6 +161,7 @@ class saimod_project extends \SYSTEM\SAI\sai_module{
$data['project'],
$data['badge'],
$data['color'],
$data['color_text'],
self::BADGE_TYPE_PROJECT_FOCUS,
$data['project'],
$data['visibility']))
@ -178,6 +173,7 @@ class saimod_project extends \SYSTEM\SAI\sai_module{
$data['project'],
$data['badge'],
$data['color'],
$data['color_text'],
self::BADGE_TYPE_PROJECT_TYPE,
$data['project'],
$data['visibility']))
@ -216,25 +212,6 @@ class saimod_project extends \SYSTEM\SAI\sai_module{
return \JsonResult::ok();
}
private static function badge_color_options($selected = null){
$colors = array(
'badge-primary',
'badge-secondary',
'badge-success',
'badge-danger',
'badge-warning',
'badge-info',
'badge-light',
'badge-dark'
);
$result = '';
foreach($colors as $color){
$vars = array('value' => $color, 'selected' => $color == $selected ? 'selected' : '');
$result .= \SYSTEM\PAGE\replace::replaceFile((new \SAI\PPROJECT('tpl/badge_color_option.tpl'))->SERVERPATH(),$vars);
}
return $result;
}
public static function menu(){
return new \SYSTEM\SAI\sai_module_menu( 101,
\SYSTEM\SAI\sai_module_menu::POISITION_LEFT,

View File

@ -29,8 +29,8 @@ class INSERT_BADGE extends \SYSTEM\DB\QP {
*/
public static function mysql(){return
'INSERT INTO `badges`'.
' (`type`, `ref_id`, `badge`, `color`, `order`, `visible`)'.
' VALUES ( ?, ?, ? ,?, (IFNULL((SELECT MAX(`order`)+1 FROM `badges` as `b` WHERE `type` = ? AND `ref_id` = ?),1)), ?);';
' (`type`, `ref_id`, `badge`, `color`, `color_text`, `order`, `visible`)'.
' VALUES ( ?, ?, ? ,?, ?, (IFNULL((SELECT MAX(`order`)+1 FROM `badges` as `b` WHERE `type` = ? AND `ref_id` = ?),1)), ?);';
}
}

View File

@ -1 +0,0 @@
<option value="${value}" ${selected}>${value}</option>

View File

@ -1 +1 @@
<span class="badge ${color}">${badge}</span>
<span class="badge" style="background-color: #${color}; color: #${color_text};">${badge}</span>

View File

@ -1,7 +1,8 @@
<tr>
<td><span class="badge ${color}">${badge}</span></td>
<td><span class="badge" style="background-color: #${color}; color: #${color_text}">${badge}</span></td>
<td>${badge}</td>
<td>${color}</td>
<td>${color_text}</td>
<td style="font-size: 30px">
<a href="#" class="badge-order-up" badge="${id}" type="${type}" ref_id="${ref_id}" order="${order}"><i class="fa fa-caret-up"></i></a>
<a href="#" class="badge-order-down" badge="${id}" type="${type}" ref_id="${ref_id}" order="${order}" order="${order}"><i class="fa fa-caret-down"></i></a>

View File

@ -53,6 +53,7 @@
<th>Preview</th>
<th>Badge</th>
<th>Color</th>
<th>Text Color</th>
<th>Order</th>
<th>Visible</th>
<th>
@ -63,13 +64,10 @@
<tbody>
${focus}
<tr>
<td><span class="badge badge-primary"></span></td>
<td><span class="badge" style=""></span></td>
<td><input id="input-focus-badge" class="form-control" type="text" style="width: 100%"/></td>
<td>
<select id="input-focus-color" class="form-control">
${badge_colors}
</select>
</td>
<td><input id="input-focus-color" class="form-control" type="text" minlength="6" maxlength="6" style="width: 100%"/></td>
<td><input id="input-focus-color-text" class="form-control" type="text" minlength="6" maxlength="6" style="width: 100%"/></td>
<td></td>
<td>
<select id="input-focus-visibility" class="form-control">
@ -106,13 +104,10 @@
<tbody>
${type}
<tr>
<td><span class="badge badge-primary"></span></td>
<td><span class="badge"></span></td>
<td><input id="input-type-badge" class="form-control" type="text" style="width: 100%"/></td>
<td>
<select id="input-type-color" class="form-control">
${badge_colors}
</select>
</td>
<td><input id="input-type-color" class="form-control" type="text" minlength="6" maxlength="6" style="width: 100%"/></td>
<td><input id="input-type-color-text" class="form-control" type="text" minlength="6" maxlength="6" style="width: 100%"/></td>
<td></td>
<td>
<select id="input-type-visibility" class="form-control">