Skip to content

Commit

Permalink
Merge pull request #1705 from LiveHelperChat/master-angular-dropdown
Browse files Browse the repository at this point in the history
Angular dropdown
  • Loading branch information
remdex authored Oct 14, 2021
2 parents 2bd3331 + ce8682a commit 49f4bb1
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 31 deletions.
5 changes: 5 additions & 0 deletions lhc_web/design/defaulttheme/css/app-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -1924,4 +1924,9 @@ html {
0%{opacity: 0.5;}
50%{opacity: 1;}
100%{opacity: 0.5;}
}

.dropdown-toggle.btn-department-dropdown::after{
float:right;
margin-top: 8px;
}
5 changes: 5 additions & 0 deletions lhc_web/design/defaulttheme/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1920,4 +1920,9 @@ html {

.filter-online-active .online-user-filter-row:not(.online_user){
display: none;
}

.dropdown-toggle.btn-department-dropdown::after{
float:right;
margin-top: 8px;
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions lhc_web/design/defaulttheme/js/angular.lhc.replacegenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ lhcAppControllers.controller('CannedReplaceCtrl',['$scope','$http','$location','
'dep_id': "0",
'priority' : 0,
});

setTimeout(function(){
$('.btn-block-department').makeDropdown();
},1000);

};

this.addCondition = function(items) {
Expand All @@ -53,4 +58,9 @@ lhcAppControllers.controller('CannedReplaceCtrl',['$scope','$http','$location','
that.move(field,list,1);
}

setTimeout(function(){
$('.btn-block-department').makeDropdown();
},1500);


}]);

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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

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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions lhc_web/design/defaulttheme/js/lh.js
Original file line number Diff line number Diff line change
Expand Up @@ -4400,6 +4400,12 @@ $.fn.makeDropdown = function() {
$(this).find('.btn-department-dropdown').text((itemsSelectedCount == 1 ? defaultSelectedText : '['+itemsSelectedCount+'] ') + (itemsSelectedCount != 1 ? $(this).find('.btn-department-dropdown').attr('data-text') : ''));
}

var selectedItemsRadio = $(this).find('li input:checked');

if (selectedItemsRadio.length == 1) {
$(this).find('.btn-department-dropdown').text(selectedItemsRadio.first().parent().text());
}

var _thisItem = $(this);

_thisItem.on("change","li input:checkbox",function() {
Expand Down Expand Up @@ -4432,6 +4438,12 @@ $.fn.makeDropdown = function() {
}
});

_thisItem.on("change","li input:radio",function() {
if ($(this).is(':checked')) {
_thisItem.find('.btn-department-dropdown').text($(this).parent().text());
}
})

$(this).on('click','.delete-item',function () {
_thisItem.find('input[value='+$(this).attr('data-value')+']').prop('checked',false);
$(this).parent().remove();
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/design/defaulttheme/js/lh.min.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions lhc_web/design/defaulttheme/tpl/lhcannedmsg/form_replace.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,24 @@

<div class="form-group">
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Department filter');?></label>
<?php echo erLhcoreClassRenderHelper::renderCombobox( array (
'input_name' => 'department_id',
'ng-model' => 'combination.dep_id',
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
'input_name' => 'department_id-{{$index}}',
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Choose department'),
'selected_id' => "0",
'css_class' => 'form-control form-control-sm',
'ng-model' => 'combination.dep_id',
'type' => 'radio',
'data_prop' => 'data-limit="1"',
'css_class' => 'form-control',
'display_name' => 'name',
'list_function_params' => array(),
'list_function' => 'erLhcoreClassModelDepartament::getList'
'show_optional' => true,
'list_function_params' => array('limit' => false),
'list_function' => 'erLhcoreClassModelDepartament::getList',
)); ?>
</div>

<h6>Advanced filtering</h6>
<h6><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Advanced filtering');?></h6>

<button type="button" class="btn btn-sm btn-secondary" ng-click="crc.addCondition(combination)">Add condition</button>
<button type="button" class="btn btn-sm btn-secondary" ng-click="crc.addCondition(combination)"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Add condition');?></button>

<div class="row pt-1" ng-repeat="conditionItem in combination.conditions track by $index" >
<div class="col-9">
Expand Down Expand Up @@ -110,7 +113,4 @@

</div>
</div>



</div>
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,47 @@
'validation_definition' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'boolean'
)),
'dep_id' => array(
/*'dep_id' => array(
'type' => 'combobox',
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Department'),
'required' => false,
'frontend' => 'dep_frontend',
'source' => 'erLhcoreClassModelDepartament::getList',
'hide_optional' => !empty($departmentFilterdefault = erLhcoreClassUserDep::conditionalDepartmentFilter()),
'params_call' => $departmentFilterdefault,
'validation_definition' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'int'
)),*/

'dep_id' => array(
'type' => 'multi_dropdown',
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Department'),
'required' => false,
'data_prop' => 'data-limit="1"',
'no_selector' => true,
'type_element' => 'radio',
'frontend' => 'dep_frontend',
'source' => 'erLhcoreClassModelDepartament::getList',
'hide_optional' => !empty($departmentFilterdefault = erLhcoreClassUserDep::conditionalDepartmentFilter()),
'params_call' => $departmentFilterdefault,
'validation_definition' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'int'
)),

/*echo erLhcoreClassRenderHelper::renderMultiDropdown(array(
'input_name' => 'department_id',
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel', 'Choose department'),
'selected_id' => "0",
'ng-model' => 'combination.dep_id',
'type' => 'radio',
'data_prop' => 'data-limit="1"',
'css_class' => 'form-control',
'display_name' => 'name',
'list_function_params' => array('limit' => false),
'list_function' => 'erLhcoreClassModelDepartament::getList',
));*/


'user_id' => array(
'type' => 'combobox',
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'User'),
Expand Down
31 changes: 30 additions & 1 deletion lhc_web/lib/core/lhabstract/lhabstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static function renderInput($name, $attr, $object, $defaultValue = '')
foreach ($items as $item) {
$selected = in_array($item->id, $object->$name) ? 'checked="checked"' : '';
$nameAttr = isset($attr['name_attr']) ? $item->{$attr['name_attr']} : ((string)$item);
$return .= '<div ng-non-bindable class="col-' . $attr['col_size'] . '"><label><input type="checkbox" name="AbstractInput_' . $name . '[]" ' . $selected . ' value="' . $item->id . '">' . htmlspecialchars($nameAttr) . '</label></div>';
$return .= '<div ng-non-bindable class="col-' . $attr['col_size'] . '"><label><input class="mr-1" type="checkbox" name="AbstractInput_' . $name . '[]" ' . $selected . ' value="' . $item->id . '">' . htmlspecialchars($nameAttr) . '</label></div>';

/*$nameAttr = isset($attr['name_attr']) ? $item->{$attr['name_attr']} : ((string)$item);
$return .= '<option value="'.$item->id.'" '.$selected.'>'.((string)$nameAttr).'</option>';*/
Expand All @@ -226,6 +226,35 @@ public static function renderInput($name, $attr, $object, $defaultValue = '')
return '<pre ng-non-bindable>' . htmlspecialchars($object->$name) . '</pre>';
break;

case 'multi_dropdown':
$paramsRender = [
'input_name' => 'AbstractInput_' . $name ,
'wrapper_class' => 'dropdown-AbstractInput_' . $name ,
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Choose'),
'selected_id' => $object->$name,
'css_class' => 'form-control',
'display_name' => $attr['name_attr'] ?? 'name',
'list_function_params' => $attr['params_call'],
'list_function' => $attr['source']
];

if (!isset($attr['hide_optional']) || $attr['hide_optional'] == false) {
$paramsRender['show_optional'] = true;
}

if (isset($attr['data_prop']) && $attr['data_prop'] != '') {
$paramsRender['data_prop'] = $attr['data_prop'];
}

if (isset($attr['type_element']) && $attr['type_element'] != '') {
$paramsRender['type'] = $attr['type_element'];
}

if (isset($attr['no_selector']) && $attr['no_selector'] == true) {
$paramsRender['no_selector'] = true;
}

return erLhcoreClassRenderHelper::renderMultiDropdown($paramsRender). '<script>$(function() {$(\'.'.$paramsRender['wrapper_class'].'\').makeDropdown();})</script>';
default:
break;
}
Expand Down
Loading

0 comments on commit 49f4bb1

Please sign in to comment.