Search ext - Show translated labels for operators
authorColeman Watts <coleman@civicrm.org>
Sat, 29 Aug 2020 23:19:06 +0000 (19:19 -0400)
committerColeman Watts <coleman@civicrm.org>
Sat, 29 Aug 2020 23:19:06 +0000 (19:19 -0400)
ext/search/CRM/Search/Page/Ang.php
ext/search/ang/search/crmSearchClause.html
ext/search/ang/search/crmSearchValue.directive.js
ext/search/css/search.css

index 936f92edd619664280f1c3f45b14455b7576c391..b6a03e2bbf76d216dfb430ace86f300d39785ff2 100644 (file)
@@ -32,7 +32,7 @@ class CRM_Search_Page_Ang extends CRM_Core_Page {
 
     // Add client-side vars for the search UI
     $vars = [
-      'operators' => \Civi\Api4\Utils\CoreUtil::getOperators(),
+      'operators' => CRM_Utils_Array::makeNonAssociative($this->getOperators()),
       'schema' => $this->schema,
       'links' => $this->getLinks(),
       'loadOptions' => $this->loadOptions,
@@ -55,6 +55,29 @@ class CRM_Search_Page_Ang extends CRM_Core_Page {
     parent::run();
   }
 
+  /**
+   * @return string[]
+   */
+  private function getOperators() {
+    return [
+      '=' => '=',
+      '!=' => '≠',
+      '>' => '>',
+      '<' => '<',
+      '>=' => '≥',
+      '<=' => '≤',
+      'CONTAINS' => ts('Contains'),
+      'IN' => ts('Is In'),
+      'NOT IN' => ts('Not In'),
+      'LIKE' => ts('Is Like'),
+      'NOT LIKE' => ts('Not Like'),
+      'BETWEEN' => ts('Is Between'),
+      'NOT BETWEEN' => ts('Not Between'),
+      'IS NULL' => ts('Is Null'),
+      'IS NOT NULL' => ts('Not Null'),
+    ];
+  }
+
   /**
    * Populates $this->schema & $this->allowedEntities
    */
index 1a0567f9cf7646911c78fe3f90f957315357aa68..97ef49621fadd2d233c3f3ff17b788c26d44a0ca 100644 (file)
@@ -16,7 +16,7 @@
       </div>
       <div ng-if="!$ctrl.conjunctions[clause[0]]" class="api4-input-group">
         <input class="form-control" ng-model="clause[0]" crm-ui-select="{data: data.fields, allowClear: true, placeholder: 'Field'}" />
-        <select class="form-control api4-operator" ng-model="clause[1]" ng-options="o for o in $ctrl.operators" ></select>
+        <select class="form-control api4-operator" ng-model="clause[1]" ng-options="o.key as o.value for o in $ctrl.operators" ></select>
         <input class="form-control" ng-model="clause[2]" crm-search-value="{field: clause[0], op: clause[1], format: data.format}" />
       </div>
       <fieldset class="clearfix" ng-if="$ctrl.conjunctions[clause[0]]" crm-search-clause="{format: data.format, clauses: clause[1], op: clause[0], fields: data.fields, groupParent: data.clauses, groupIndex: index}">
index ad93d2b8788cefe66dc4baa9deaa0b718255f0d4..9e39cf1585b50059c563229efc931ae6253892a5 100644 (file)
             return;
           }
           if (inputType === 'Date') {
-            if (_.includes(['=', '!=', '<>', '>', '>=', '<', '<='], op)) {
+            if (_.includes(['=', '!=', '>', '>=', '<', '<='], op)) {
               $el.crmDatepicker({time: (field.input_attrs && field.input_attrs.time) || false});
             }
-          } else if (_.includes(['=', '!=', '<>', 'IN', 'NOT IN', 'CONTAINS'], op) && (field.fk_entity || field.options || dataType === 'Boolean')) {
+          } else if (_.includes(['=', '!=', 'IN', 'NOT IN', 'CONTAINS'], op) && (field.fk_entity || field.options || dataType === 'Boolean')) {
             if (field.options) {
               if (field.options === true) {
                 $el.addClass('loading');
index 70b329b563245bf14ed60b635575bd15f3f88ba3..554f1f724b6e1baca41e8183571ea5ee35a3e850 100644 (file)
 }
 
 #bootstrap-theme.crm-search .api4-operator {
-  width: 90px;
+  width: 110px;
 }
 
 #bootstrap-theme.crm-search .api4-add-where-group-menu {