Search ext: Reorganize into searchAdmin and searchActions modules
authorColeman Watts <coleman@civicrm.org>
Tue, 13 Oct 2020 15:54:36 +0000 (11:54 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 14 Oct 2020 13:13:31 +0000 (09:13 -0400)
29 files changed:
ext/search/CRM/Search/Page/Admin.php [moved from ext/search/CRM/Search/Page/Ang.php with 64% similarity]
ext/search/Civi/Search/Actions.php [new file with mode: 0644]
ext/search/ang/searchActions.ang.php [new file with mode: 0644]
ext/search/ang/searchActions.module.js [new file with mode: 0644]
ext/search/ang/searchActions/SaveSmartGroup.ctrl.js [moved from ext/search/ang/search/SaveSmartGroup.ctrl.js with 93% similarity]
ext/search/ang/searchActions/crmSearchActionDelete.ctrl.js [moved from ext/search/ang/search/crmSearchActions/crmSearchActionDelete.ctrl.js with 80% similarity]
ext/search/ang/searchActions/crmSearchActionDelete.html [moved from ext/search/ang/search/crmSearchActions/crmSearchActionDelete.html with 100% similarity]
ext/search/ang/searchActions/crmSearchActionUpdate.ctrl.js [moved from ext/search/ang/search/crmSearchActions/crmSearchActionUpdate.ctrl.js with 92% similarity]
ext/search/ang/searchActions/crmSearchActionUpdate.html [moved from ext/search/ang/search/crmSearchActions/crmSearchActionUpdate.html with 100% similarity]
ext/search/ang/searchActions/crmSearchActions.component.js [moved from ext/search/ang/search/crmSearchActions.component.js with 66% similarity]
ext/search/ang/searchActions/crmSearchActions.html [moved from ext/search/ang/search/crmSearchActions.html with 67% similarity]
ext/search/ang/searchActions/saveSmartGroup.directive.js [new file with mode: 0644]
ext/search/ang/searchActions/saveSmartGroup.html [moved from ext/search/ang/search/saveSmartGroup.html with 86% similarity]
ext/search/ang/searchAdmin.ang.php [moved from ext/search/ang/search.ang.php with 53% similarity]
ext/search/ang/searchAdmin.module.js [moved from ext/search/ang/search.module.js with 98% similarity]
ext/search/ang/searchAdmin/crmSearch.component.js [moved from ext/search/ang/search/crmSearch.component.js with 94% similarity]
ext/search/ang/searchAdmin/crmSearch.html [moved from ext/search/ang/search/crmSearch.html with 62% similarity]
ext/search/ang/searchAdmin/crmSearch/controls.html [moved from ext/search/ang/search/crmSearch/controls.html with 88% similarity]
ext/search/ang/searchAdmin/crmSearch/criteria.html [moved from ext/search/ang/search/crmSearch/criteria.html with 91% similarity]
ext/search/ang/searchAdmin/crmSearch/debug.html [moved from ext/search/ang/search/crmSearch/debug.html with 100% similarity]
ext/search/ang/searchAdmin/crmSearch/pager.html [moved from ext/search/ang/search/crmSearch/pager.html with 100% similarity]
ext/search/ang/searchAdmin/crmSearch/results.html [moved from ext/search/ang/search/crmSearch/results.html with 100% similarity]
ext/search/ang/searchAdmin/crmSearchClause.component.js [moved from ext/search/ang/search/crmSearchClause.component.js with 94% similarity]
ext/search/ang/searchAdmin/crmSearchClause.html [moved from ext/search/ang/search/crmSearchClause.html with 100% similarity]
ext/search/ang/searchAdmin/crmSearchFunction.component.js [moved from ext/search/ang/search/crmSearchFunction.component.js with 91% similarity]
ext/search/ang/searchAdmin/crmSearchFunction.html [moved from ext/search/ang/search/crmSearchFunction.html with 100% similarity]
ext/search/ang/searchAdmin/crmSearchValue.directive.js [moved from ext/search/ang/search/crmSearchValue.directive.js with 97% similarity]
ext/search/templates/CRM/Search/Page/Admin.tpl [moved from ext/search/templates/CRM/Search/Page/Ang.tpl with 100% similarity]
ext/search/xml/Menu/search.xml

similarity index 64%
rename from ext/search/CRM/Search/Page/Ang.php
rename to ext/search/CRM/Search/Page/Admin.php
index 22cab1dcfabc6e89bfecc4a471ed6c3f84353b74..c1d06ab0f83b76c69423617fdaa68ef3b159be4d 100644 (file)
@@ -1,6 +1,18 @@
 <?php
-
-class CRM_Search_Page_Ang extends CRM_Core_Page {
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Angular base page for search admin
+ */
+class CRM_Search_Page_Admin extends CRM_Core_Page {
   /**
    * @var string[]
    */
@@ -36,18 +48,16 @@ class CRM_Search_Page_Ang extends CRM_Core_Page {
       'schema' => $this->schema,
       'links' => $this->getLinks(),
       'loadOptions' => $this->loadOptions,
-      'actions' => $this->getActions(),
       'functions' => CRM_Api4_Page_Api4Explorer::getSqlFunctions(),
     ];
 
     Civi::resources()
-      ->addPermissions(['edit groups', 'administer reserved groups'])
       ->addBundle('bootstrap3')
       ->addVars('search', $vars);
 
     // Load angular module
     $loader = new Civi\Angular\AngularLoader();
-    $loader->setModules(['search']);
+    $loader->setModules(['searchAdmin']);
     $loader->setPageName('civicrm/search');
     $loader->useApp([
       'defaultRoute' => '/create/Contact',
@@ -134,65 +144,4 @@ class CRM_Search_Page_Ang extends CRM_Core_Page {
     return array_filter($results);
   }
 
-  /**
-   * @return array[]
-   */
-  private function getActions() {
-    // Note: the placeholder %1 will be replaced with entity name on the clientside
-    $actions = [
-      'export' => [
-        'title' => ts('Export %1'),
-        'icon' => 'fa-file-excel-o',
-        'entities' => array_keys(CRM_Export_BAO_Export::getComponents()),
-        'crmPopup' => [
-          'path' => "'civicrm/export/standalone'",
-          'query' => "{entity: entity, id: ids.join(',')}",
-        ],
-      ],
-      'update' => [
-        'title' => ts('Update %1'),
-        'icon' => 'fa-save',
-        'entities' => [],
-        'uiDialog' => ['templateUrl' => '~/search/crmSearchActions/crmSearchActionUpdate.html'],
-      ],
-      'delete' => [
-        'title' => ts('Delete %1'),
-        'icon' => 'fa-trash',
-        'entities' => [],
-        'uiDialog' => ['templateUrl' => '~/search/crmSearchActions/crmSearchActionDelete.html'],
-      ],
-    ];
-
-    // Check permissions for update & delete actions
-    foreach ($this->allowedEntities as $entity) {
-      $result = civicrm_api4($entity, 'getActions', [
-        'where' => [['name', 'IN', ['update', 'delete']]],
-      ], ['name']);
-      foreach ($result as $action) {
-        // Contacts have their own delete action
-        if (!($entity === 'Contact' && $action === 'delete')) {
-          $actions[$action]['entities'][] = $entity;
-        }
-      }
-    }
-
-    // Add contact tasks which support standalone mode (with a 'url' property)
-    $contactTasks = CRM_Contact_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission());
-    foreach (CRM_Contact_Task::tasks() as $id => $task) {
-      if (isset($contactTasks[$id]) && !empty($task['url'])) {
-        $actions['contact.' . $id] = [
-          'title' => $task['title'],
-          'entities' => ['Contact'],
-          'icon' => $task['icon'] ?? 'fa-gear',
-          'crmPopup' => [
-            'path' => "'{$task['url']}'",
-            'query' => "{cids: ids.join(',')}",
-          ],
-        ];
-      }
-    }
-
-    return $actions;
-  }
-
 }
diff --git a/ext/search/Civi/Search/Actions.php b/ext/search/Civi/Search/Actions.php
new file mode 100644 (file)
index 0000000..4771101
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Search;
+
+/**
+ * Class Tasks
+ * @package Civi\Search
+ */
+class Actions {
+
+  /**
+   * @return array
+   */
+  public static function getActionSettings():array {
+    return [
+      'tasks' => self::getTasks(),
+      'groupOptions' => self::getGroupOptions(),
+    ];
+  }
+
+  /**
+   * @return array
+   */
+  public static function getGroupOptions():array {
+    return \Civi\Api4\Group::getFields(FALSE)
+      ->setLoadOptions(['id', 'label'])
+      ->addWhere('name', 'IN', ['group_type', 'visibility'])
+      ->execute()
+      ->indexBy('name')
+      ->column('options');
+  }
+
+  /**
+   * @return array
+   */
+  public static function getTasks():array {
+    // Note: the placeholder %1 will be replaced with entity name on the clientside
+    $tasks = [
+      'export' => [
+        'title' => ts('Export %1'),
+        'icon' => 'fa-file-excel-o',
+        'entities' => array_keys(\CRM_Export_BAO_Export::getComponents()),
+        'crmPopup' => [
+          'path' => "'civicrm/export/standalone'",
+          'query' => "{entity: entity, id: ids.join(',')}",
+        ],
+      ],
+      'update' => [
+        'title' => ts('Update %1'),
+        'icon' => 'fa-save',
+        'entities' => [],
+        'uiDialog' => ['templateUrl' => '~/searchActions/crmSearchActionUpdate.html'],
+      ],
+      'delete' => [
+        'title' => ts('Delete %1'),
+        'icon' => 'fa-trash',
+        'entities' => [],
+        'uiDialog' => ['templateUrl' => '~/searchActions/crmSearchActionDelete.html'],
+      ],
+    ];
+
+    // Add contact tasks which support standalone mode (with a 'url' property)
+    $contactTasks = \CRM_Contact_Task::permissionedTaskTitles(\CRM_Core_Permission::getPermission());
+    foreach (\CRM_Contact_Task::tasks() as $id => $task) {
+      if (isset($contactTasks[$id]) && !empty($task['url']) && $task['url'] !== 'civicrm/task/delete-contact') {
+        $tasks['contact.' . $id] = [
+          'title' => $task['title'],
+          'entities' => ['Contact'],
+          'icon' => $task['icon'] ?? 'fa-gear',
+          'crmPopup' => [
+            'path' => "'{$task['url']}'",
+            'query' => "{cids: ids.join(',')}",
+          ],
+        ];
+      }
+    }
+
+    return $tasks;
+  }
+
+}
diff --git a/ext/search/ang/searchActions.ang.php b/ext/search/ang/searchActions.ang.php
new file mode 100644 (file)
index 0000000..6699110
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+// Autoloader data for search actions.
+return [
+  'js' => [
+    'ang/searchActions.module.js',
+    'ang/searchActions/*.js',
+    'ang/searchActions/*/*.js',
+  ],
+  'partials' => [
+    'ang/searchActions',
+  ],
+  'basePages' => [],
+  'requires' => ['crmUi', 'crmUtil', 'dialogService', 'api4'],
+  'settingsFactory' => ['\Civi\Search\Actions', 'getActionSettings'],
+  'permissions' => ['edit groups', 'administer reserved groups'],
+];
diff --git a/ext/search/ang/searchActions.module.js b/ext/search/ang/searchActions.module.js
new file mode 100644 (file)
index 0000000..9f4204c
--- /dev/null
@@ -0,0 +1,7 @@
+(function(angular, $, _) {
+  "use strict";
+
+  // Declare module
+  angular.module('searchActions', CRM.angRequires('searchActions'));
+
+})(angular, CRM.$, CRM._);
similarity index 93%
rename from ext/search/ang/search/SaveSmartGroup.ctrl.js
rename to ext/search/ang/searchActions/SaveSmartGroup.ctrl.js
index 47837b2c8c10bfee694d3ebc62537bb9a8564a3d..ab6cb2144797e163012fa52d219a51f3c9288490 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').controller('SaveSmartGroup', function ($scope, $element, $timeout, crmApi4, dialogService, searchMeta) {
+  angular.module('searchActions').controller('SaveSmartGroup', function ($scope, $element, $timeout, crmApi4, dialogService, searchMeta) {
     var ts = $scope.ts = CRM.ts(),
       model = $scope.model,
       joins = _.pluck((model.api_params.join || []), 0),
@@ -53,7 +53,7 @@
     $scope.perm = {
       administerReservedGroups: CRM.checkPerm('administer reserved groups')
     };
-    $scope.groupFields = _.indexBy(_.find(CRM.vars.search.schema, {name: 'Group'}).fields, 'name');
+    $scope.groupOptions = CRM.searchActions.groupOptions;
     $element.on('change', '#api-save-search-select-group', function() {
       if ($(this).val()) {
         $scope.$apply(function() {
similarity index 80%
rename from ext/search/ang/search/crmSearchActions/crmSearchActionDelete.ctrl.js
rename to ext/search/ang/searchActions/crmSearchActionDelete.ctrl.js
index 28a401e65258d488bf47dabeadfac36db9d509ab..f81d915acf4ab153f875ad8ae1c390bfd768f0cf 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').controller('crmSearchActionDelete', function($scope, crmApi4, dialogService, searchMeta) {
+  angular.module('searchActions').controller('crmSearchActionDelete', function($scope, crmApi4, dialogService, searchMeta) {
     var ts = $scope.ts = CRM.ts(),
       model = $scope.model,
       ctrl = $scope.$ctrl = this;
similarity index 92%
rename from ext/search/ang/search/crmSearchActions/crmSearchActionUpdate.ctrl.js
rename to ext/search/ang/searchActions/crmSearchActionUpdate.ctrl.js
index a4fb759887a08965a7144565e86f9247cc62e0e8..b44acb29a939d619986b14c2674040890b01613f 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').controller('crmSearchActionUpdate', function ($scope, $timeout, crmApi4, dialogService, searchMeta) {
+  angular.module('searchActions').controller('crmSearchActionUpdate', function ($scope, $timeout, crmApi4, dialogService, searchMeta) {
     var ts = $scope.ts = CRM.ts(),
       model = $scope.model,
       ctrl = $scope.$ctrl = this;
similarity index 66%
rename from ext/search/ang/search/crmSearchActions.component.js
rename to ext/search/ang/searchActions/crmSearchActions.component.js
index 212b8d914f85b8acf26638da53fe8501cc756f49..a7bfb3cef55f7a9d922724b5494b0a150bce312f 100644 (file)
@@ -1,29 +1,44 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').component('crmSearchActions', {
+  angular.module('searchActions').component('crmSearchActions', {
     bindings: {
       entity: '<',
       refresh: '&',
       ids: '<'
     },
-    templateUrl: '~/search/crmSearchActions.html',
+    templateUrl: '~/searchActions/crmSearchActions.html',
     controller: function($scope, crmApi4, dialogService, searchMeta) {
       var ts = $scope.ts = CRM.ts(),
-        ctrl = this;
+        ctrl = this,
+        initialized = false,
+        unwatchIDs = $scope.$watch('$ctrl.ids.length', watchIDs);
 
-      this.$onInit = function() {
+      function watchIDs() {
+        if (ctrl.ids && ctrl.ids.length && !initialized) {
+          unwatchIDs();
+          initialized = true;
+          initialize();
+        }
+      }
+
+      function initialize() {
         var entityTitle = searchMeta.getEntity(ctrl.entity).titlePlural;
-        if (!ctrl.actions) {
-          var actions = _.transform(_.cloneDeep(CRM.vars.search.actions), function (actions, action) {
+        crmApi4(ctrl.entity, 'getActions', {
+          where: [['name', 'IN', ['update', 'delete']]],
+        }, ['name']).then(function(allowed) {
+          _.each(allowed, function(action) {
+            CRM.searchActions.tasks[action].entities.push(ctrl.entity);
+          });
+          var actions = _.transform(_.cloneDeep(CRM.searchActions.tasks), function(actions, action) {
             if (_.includes(action.entities, ctrl.entity)) {
               action.title = action.title.replace('%1', entityTitle);
               actions.push(action);
             }
           }, []);
           ctrl.actions = _.sortBy(actions, 'title');
-        }
-      };
+        });
+      }
 
       this.isActionAllowed = function(action) {
         return !action.number || $scope.eval('' + $ctrl.ids.length + action.number);
similarity index 67%
rename from ext/search/ang/search/crmSearchActions.html
rename to ext/search/ang/searchActions/crmSearchActions.html
index 7442efbe09e46dfb30ee55e35d9e61790f0b23ea..41696415e0d6438eace4c4bb5f2caa297bc45d4a 100644 (file)
@@ -1,5 +1,5 @@
 <div class="btn-group" title="{{:: ts('Perform action on selected items.') }}">
-  <button type="button" ng-disabled="!$ctrl.ids.length" ng-click="$ctrl.init()" class="btn form-control dropdown-toggle btn-default" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+  <button type="button" ng-disabled="!$ctrl.ids.length" class="btn form-control dropdown-toggle btn-default" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
     {{:: ts('Action') }} <span class="caret"></span>
   </button>
   <ul class="dropdown-menu" ng-if=":: $ctrl.actions">
diff --git a/ext/search/ang/searchActions/saveSmartGroup.directive.js b/ext/search/ang/searchActions/saveSmartGroup.directive.js
new file mode 100644 (file)
index 0000000..c53a387
--- /dev/null
@@ -0,0 +1,44 @@
+(function(angular, $, _) {
+  "use strict";
+
+  angular.module('searchActions').directive('saveSmartGroup', function() {
+    return {
+      bindToController: {
+        load: '<',
+        entity: '<',
+        params: '<'
+      },
+      controller: function ($scope, $element, dialogService) {
+        var ts = $scope.ts = CRM.ts(),
+          ctrl = this;
+
+        $scope.saveGroup = function () {
+          var model = {
+            title: '',
+            description: '',
+            visibility: 'User and User Admin Only',
+            group_type: [],
+            id: ctrl.load ? ctrl.load.id : null,
+            api_entity: ctrl.entity,
+            api_params: _.cloneDeep(angular.extend({}, ctrl.params, {version: 4}))
+          };
+          delete model.api_params.orderBy;
+          if (ctrl.load && ctrl.load.api_params && ctrl.load.api_params.select && ctrl.load.api_params.select[0]) {
+            model.api_params.select.unshift(ctrl.load.api_params.select[0]);
+          }
+          var options = CRM.utils.adjustDialogDefaults({
+            autoOpen: false,
+            title: ts('Save smart group')
+          });
+          dialogService.open('saveSearchDialog', '~/searchActions/saveSmartGroup.html', model, options)
+            .then(function () {
+              if (ctrl.load) {
+                ctrl.load.saved = true;
+              }
+            });
+        };
+      }
+    };
+  });
+
+})(angular, CRM.$, CRM._);
similarity index 86%
rename from ext/search/ang/search/saveSmartGroup.html
rename to ext/search/ang/searchActions/saveSmartGroup.html
index 3589ff2234015433e14eeb6f704f63a070467c4e..43686da3384ad6faf6e55204d8521e517789ee4f 100644 (file)
@@ -13,7 +13,7 @@
     <textarea class="form-control" ng-model="model.description"></textarea>
     <div class="form-inline">
       <label>{{:: ts('Group Type:') }} </label>
-      <div class="checkbox" ng-repeat="option in groupFields.group_type.options track by option.id">&nbsp;
+      <div class="checkbox" ng-repeat="option in groupOptions.group_type track by option.id">&nbsp;
         <label>
           <input type="checkbox" checklist-model="model.group_type" checklist-value="option.id">
           {{ option.label }}
@@ -22,7 +22,7 @@
     </div>
     <div class="form-inline">
       <label>{{:: ts('Visibility:') }}</label>
-      <select class="form-control" ng-model="model.visibility" ng-options="item.id as item.label for item in groupFields.visibility.options track by item.id" crm-ui-select></select>
+      <select class="form-control" ng-model="model.visibility" ng-options="item.id as item.label for item in groupOptions.visibility track by item.id" crm-ui-select></select>
     </div>
     <hr />
     <div class="buttons pull-right">
similarity index 53%
rename from ext/search/ang/search.ang.php
rename to ext/search/ang/searchAdmin.ang.php
index 67275088f1f9520b0320ea0f89665c2224f0f026..1c60e31ee5978808e32935d9a24f3d4060886148 100644 (file)
@@ -2,16 +2,16 @@
 // Autoloader data for search builder.
 return [
   'js' => [
-    'ang/*.js',
-    'ang/search/*.js',
-    'ang/search/*/*.js',
+    'ang/searchAdmin.module.js',
+    'ang/searchAdmin/*.js',
+    'ang/searchAdmin/*/*.js',
   ],
   'css' => [
     'css/*.css',
   ],
   'partials' => [
-    'ang/search',
+    'ang/searchAdmin',
   ],
   'basePages' => [],
-  'requires' => ['crmUi', 'crmUtil', 'ngRoute', 'crmRouteBinder', 'ui.sortable', 'ui.bootstrap', 'dialogService', 'api4'],
+  'requires' => ['crmUi', 'crmUtil', 'ngRoute', 'crmRouteBinder', 'ui.sortable', 'ui.bootstrap', 'dialogService', 'api4', 'searchActions'],
 ];
similarity index 98%
rename from ext/search/ang/search.module.js
rename to ext/search/ang/searchAdmin.module.js
index 291552c3db51c8577accb0501bbc38d1694d16bf..7132e7eb6fca3f72bf84a06155cccd4cbac1c71f 100644 (file)
@@ -8,7 +8,7 @@
     undefined;
 
   // Declare module and route/controller/services
-  angular.module('search', CRM.angRequires('search'))
+  angular.module('searchAdmin', CRM.angRequires('searchAdmin'))
 
     .config(function($routeProvider) {
       $routeProvider.when('/:mode/:entity/:name?', {
similarity index 94%
rename from ext/search/ang/search/crmSearch.component.js
rename to ext/search/ang/searchAdmin/crmSearch.component.js
index 49c99081722035bf0d45069800d3fc71fa00ad74..7ebea92db2d90b0d358bbf8ed3660fee4f6b8bf2 100644 (file)
@@ -1,12 +1,12 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').component('crmSearch', {
+  angular.module('searchAdmin').component('crmSearch', {
     bindings: {
       entity: '=',
       load: '<'
     },
-    templateUrl: '~/search/crmSearch.html',
+    templateUrl: '~/searchAdmin/crmSearch.html',
     controller: function($scope, $element, $timeout, crmApi4, dialogService, searchMeta, formatForSelect2) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
         loadFieldOptions();
       };
 
-      $scope.saveGroup = function() {
-        var model = {
-          title: '',
-          description: '',
-          visibility: 'User and User Admin Only',
-          group_type: [],
-          id: ctrl.load ? ctrl.load.id : null,
-          api_entity: ctrl.entity,
-          api_params: _.cloneDeep(angular.extend({}, ctrl.params, {version: 4}))
-        };
-        delete model.api_params.orderBy;
-        if (ctrl.load && ctrl.load.api_params && ctrl.load.api_params.select && ctrl.load.api_params.select[0]) {
-          model.api_params.select.unshift(ctrl.load.api_params.select[0]);
-        }
-        var options = CRM.utils.adjustDialogDefaults({
-          autoOpen: false,
-          title: ts('Save smart group')
-        });
-        dialogService.open('saveSearchDialog', '~/search/saveSmartGroup.html', model, options)
-          .then(function() {
-            if (ctrl.load) {
-              ctrl.load.saved = true;
-            }
-          });
-      };
     }
   });
 
similarity index 62%
rename from ext/search/ang/search/crmSearch.html
rename to ext/search/ang/searchAdmin/crmSearch.html
index 5c6a010e37f50536419050a16eaf02739486ef50..bd18642a7703ac7bd13b48bb2257c957151a236b 100644 (file)
   </div>
 
   <form>
-    <div ng-include="'~/search/crmSearch/criteria.html'"></div>
-    <div ng-include="'~/search/crmSearch/controls.html'"></div>
-    <div ng-include="'~/search/crmSearch/debug.html'" ng-if="$ctrl.debug"></div>
-    <div ng-include="'~/search/crmSearch/results.html'" class="crm-search-results"></div>
-    <div ng-include="'~/search/crmSearch/pager.html'"></div>
+    <div ng-include="'~/searchAdmin/crmSearch/criteria.html'"></div>
+    <div ng-include="'~/searchAdmin/crmSearch/controls.html'"></div>
+    <div ng-include="'~/searchAdmin/crmSearch/debug.html'" ng-if="$ctrl.debug"></div>
+    <div ng-include="'~/searchAdmin/crmSearch/results.html'" class="crm-search-results"></div>
+    <div ng-include="'~/searchAdmin/crmSearch/pager.html'"></div>
   </form>
 </div>
similarity index 88%
rename from ext/search/ang/search/crmSearch/controls.html
rename to ext/search/ang/searchAdmin/crmSearch/controls.html
index ce1f843e0286aabcb0862131c6f206b7f60e1051..79e4dfc3b5e44444d56953e865df1b4ec0df7632 100644 (file)
@@ -18,7 +18,7 @@
     </button>
     <ul class="dropdown-menu">
       <li ng-if=":: $ctrl.perm.editGroups">
-        <a href ng-click="saveGroup()">{{:: ts('Smart Group') }}</a>
+        <a href save-smart-group load="$ctrl.load" entity="$ctrl.entity" params="$ctrl.params" ng-click="saveGroup()">{{:: ts('Smart Group') }}</a>
       </li>
     </ul>
   </div>
similarity index 91%
rename from ext/search/ang/search/crmSearch/criteria.html
rename to ext/search/ang/searchAdmin/crmSearch/criteria.html
index a52979c8be66513dbef08c853e9e31c6df876d80..606a50a6ad4aa4c18633e14bf4ccc8838017b9d0 100644 (file)
@@ -44,7 +44,9 @@
     <div class="navbar-form clearfix" ng-if="$ctrl.load">
       <div class="form-group pull-right">
         <label>{{ $ctrl.load.title }}</label>
-        <button class="btn btn-default" ng-disabled="$ctrl.load.saved" ng-click="saveGroup()">{{ $ctrl.load.saved ? ts('Saved') : ts('Save') }}</button>
+        <button ng-if=":: $ctrl.perm.editGroups" save-smart-group load="$ctrl.load" entity="$ctrl.entity" params="$ctrl.params" class="btn btn-default" ng-disabled="$ctrl.load.saved" ng-click="saveGroup()">
+          {{ $ctrl.load.saved ? ts('Saved') : ts('Save') }}
+        </button>
       </div>
     </div>
     <fieldset class="api4-clause-fieldset">
similarity index 94%
rename from ext/search/ang/search/crmSearchClause.component.js
rename to ext/search/ang/searchAdmin/crmSearchClause.component.js
index 3fb1a01d6f4f2f57708068b16d6c213a13533e75..3258d57bfcc450ac71cdbb6bc1b5f80c48a2c774 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').component('crmSearchClause', {
+  angular.module('searchAdmin').component('crmSearchClause', {
     bindings: {
       fields: '<',
       clauses: '<',
@@ -11,7 +11,7 @@
       label: '@',
       deleteGroup: '&'
     },
-    templateUrl: '~/search/crmSearchClause.html',
+    templateUrl: '~/searchAdmin/crmSearchClause.html',
     controller: function ($scope, $element, $timeout) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
similarity index 91%
rename from ext/search/ang/search/crmSearchFunction.component.js
rename to ext/search/ang/searchAdmin/crmSearchFunction.component.js
index 1b2c45832d85c5b2ee7f56b0ff1510f46feb0281..2b8448b55d95eaf86951507791e951c42b4340b2 100644 (file)
@@ -1,12 +1,12 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').component('crmSearchFunction', {
+  angular.module('searchAdmin').component('crmSearchFunction', {
     bindings: {
       expr: '=',
       cat: '<'
     },
-    templateUrl: '~/search/crmSearchFunction.html',
+    templateUrl: '~/searchAdmin/crmSearchFunction.html',
     controller: function($scope, formatForSelect2, searchMeta) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
similarity index 97%
rename from ext/search/ang/search/crmSearchValue.directive.js
rename to ext/search/ang/searchAdmin/crmSearchValue.directive.js
index 9e39cf1585b50059c563229efc931ae6253892a5..2f3b7f5b20c48f626879b35be6810a82afbdf53a 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('search').directive('crmSearchValue', function($interval, searchMeta, formatForSelect2) {
+  angular.module('searchAdmin').directive('crmSearchValue', function($interval, searchMeta, formatForSelect2) {
     return {
       scope: {
         data: '=crmSearchValue'
index d57a0c52ce6ec9ca04023c6cc3efd4e2ee8b2659..b5657b94fc66b9dc742d07cf3e418cb8959af7ae 100644 (file)
@@ -2,7 +2,7 @@
 <menu>
   <item>
     <path>civicrm/search</path>
-    <page_callback>CRM_Search_Page_Ang</page_callback>
+    <page_callback>CRM_Search_Page_Admin</page_callback>
     <access_arguments>access CiviCRM</access_arguments>
   </item>
 </menu>