-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19395 from colemanw/afformTypes
Tabbed interface for organizing afforms by type
- Loading branch information
Showing
62 changed files
with
775 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?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 | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
/** | ||
* Base page for Afform admin | ||
*/ | ||
class CRM_AfformAdmin_Page_Base extends CRM_Core_Page { | ||
|
||
public function run() { | ||
$breadCrumb = [ | ||
'title' => ts('Forms'), | ||
'url' => CRM_Utils_System::url('civicrm/admin/afform', NULL, FALSE, '/'), | ||
]; | ||
CRM_Utils_System::appendBreadCrumb([$breadCrumb]); | ||
|
||
// Load angular module | ||
$loader = new Civi\Angular\AngularLoader(); | ||
$loader->setPageName('civicrm/admin/afform'); | ||
$loader->useApp(); | ||
$loader->load(); | ||
parent::run(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
// Angular module for afform gui editor | ||
return [ | ||
'js' => [ | ||
'ang/afAdmin.js', | ||
'ang/afAdmin/*.js', | ||
'ang/afAdmin/*/*.js', | ||
], | ||
'css' => [], | ||
'partials' => ['ang/afAdmin'], | ||
'requires' => ['api4', 'afGuiEditor', 'crmRouteBinder'], | ||
'settingsFactory' => ['CRM_AfformAdmin_Utils', 'getAdminSettings'], | ||
'basePages' => ['civicrm/admin/afform'], | ||
'bundles' => ['bootstrap3'], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(function(angular, $, _) { | ||
"use strict"; | ||
angular.module('afAdmin', CRM.angRequires('afAdmin')) | ||
|
||
.config(function($routeProvider) { | ||
$routeProvider.when('/', { | ||
controller: 'afAdminList', | ||
reloadOnSearch: false, | ||
templateUrl: '~/afAdmin/afAdminList.html', | ||
resolve: { | ||
// Load data for lists | ||
afforms: function(crmApi4) { | ||
return crmApi4('Afform', 'get', { | ||
select: ['name', 'title', 'type', 'is_public', 'server_route', 'has_local', 'has_base'], | ||
orderBy: {title: 'ASC'} | ||
}); | ||
} | ||
} | ||
}); | ||
$routeProvider.when('/create/:type', { | ||
controller: 'afAdminGui', | ||
template: '<af-gui-editor type="$ctrl.type"></af-gui-editor>', | ||
}); | ||
$routeProvider.when('/edit/:name', { | ||
controller: 'afAdminGui', | ||
template: '<af-gui-editor name="$ctrl.name"></af-gui-editor>', | ||
}); | ||
}); | ||
|
||
})(angular, CRM.$, CRM._); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(function(angular, $, _) { | ||
"use strict"; | ||
|
||
angular.module('afAdmin').controller('afAdminGui', function($scope, $routeParams) { | ||
var ts = $scope.ts = CRM.ts(), | ||
ctrl = $scope.$ctrl = this; | ||
|
||
// Edit mode | ||
this.name = $routeParams.name; | ||
// Create mode | ||
this.type = $routeParams.type; | ||
|
||
}); | ||
|
||
})(angular, CRM.$, CRM._); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(function(angular, $, _) { | ||
"use strict"; | ||
|
||
angular.module('afAdmin').controller('afAdminList', function($scope, afforms, crmApi4, crmStatus) { | ||
var ts = $scope.ts = CRM.ts(), | ||
ctrl = $scope.$ctrl = this; | ||
|
||
$scope.crmUrl = CRM.url; | ||
|
||
this.tabs = CRM.afAdmin.afform_type; | ||
|
||
this.afforms = _.transform(afforms, function(afforms, afform) { | ||
var type = afform.type || 'system'; | ||
afforms[type] = afforms[type] || []; | ||
afforms[type].push(afform); | ||
}, {}); | ||
|
||
$scope.$bindToRoute({ | ||
expr: '$ctrl.tab', | ||
param: 'tab', | ||
format: 'raw', | ||
default: ctrl.tabs[0].name | ||
}); | ||
|
||
this.revert = function(afform) { | ||
var index = _.findIndex(ctrl.afforms[ctrl.tab], {name: afform.name}); | ||
if (index > -1) { | ||
var apiOps = [['Afform', 'revert', {where: [['name', '=', afform.name]]}]]; | ||
if (afform.has_base) { | ||
apiOps.push(['Afform', 'get', { | ||
where: [['name', '=', afform.name]], | ||
select: ['name', 'title', 'type', 'is_public', 'server_route', 'has_local', 'has_base'] | ||
}, 0]); | ||
} | ||
var apiCall = crmStatus( | ||
afform.has_base ? {start: ts('Reverting...')} : {start: ts('Deleting...'), success: ts('Deleted')}, | ||
crmApi4(apiOps) | ||
); | ||
if (afform.has_base) { | ||
afform.has_local = false; | ||
apiCall.then(function(result) { | ||
ctrl.afforms[ctrl.tab][index] = result[1]; | ||
}); | ||
} else { | ||
ctrl.afforms[ctrl.tab].splice(index, 1); | ||
} | ||
} | ||
}; | ||
}); | ||
|
||
})(angular, CRM.$, CRM._); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<div id="bootstrap-theme" class="afadmin-list"> | ||
<h1 crm-page-title>{{:: ts('Configurable Forms') }}</h1> | ||
|
||
<div class="form-inline text-right"> | ||
<a class="btn btn-primary" href="#/create/form"> | ||
<i class="crm-i fa-plus"></i> | ||
{{:: ts('New Form') }} | ||
</a> | ||
</div> | ||
|
||
<ul class="nav nav-tabs"> | ||
<li role="presentation" ng-repeat="tab in $ctrl.tabs" ng-class="{active: tab.name === $ctrl.tab}"> | ||
<a href ng-click="$ctrl.tab = tab.name"><i class="crm-i {{ tab.icon }}"></i> {{:: tab.label }}</a> | ||
</li> | ||
</ul> | ||
|
||
<div class="form-inline"> | ||
<input class="form-control" type="search" ng-model="$ctrl.search" placeholder="{{:: ts('Filter') }}"> | ||
</div> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>{{:: ts('Title') }}</th> | ||
<th>{{:: ts('Name') }}</th> | ||
<th>{{:: ts('Server Route') }}</th> | ||
<th>{{:: ts('Frontend?') }}</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="afform in $ctrl.afforms[$ctrl.tab] | filter:$ctrl.search"> | ||
<td>{{afform.title}}</td> | ||
<td> | ||
<code>{{afform.name}}</code> | ||
</td> | ||
<td> | ||
<a ng-if="afform.server_route" ng-href="{{ crmUrl(afform.server_route) }}" target="_blank"> | ||
<code>{{afform.server_route}}</code> | ||
</a> | ||
</td> | ||
<td>{{afform.is_public ? ts('Frontend') : ts('Backend')}}</td> | ||
<td> | ||
<a href="#/edit/{{ afform.name }}" class="btn btn-xs btn-primary">{{ ts('Edit') }}</a> | ||
<a href ng-if="afform.has_local" class="btn btn-xs btn-danger" crm-confirm="{type: afform.has_base ? 'revert' : 'delete', obj: afform}" on-yes="$ctrl.revert(afform)"> | ||
{{ afform.has_base ? ts('Revert') : ts('Delete') }} | ||
</a> | ||
</td> | ||
</tr> | ||
<tr ng-if="!$ctrl.afforms[$ctrl.tab] || $ctrl.afforms[$ctrl.tab].length === 0"> | ||
<td colspan="9"> | ||
<p class="messages status no-popup text-center"> | ||
{{:: ts('None Found')}} | ||
</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.