Skip to content

Commit

Permalink
PRESIDECMS-2960 Update data manager sort records screen for customisa…
Browse files Browse the repository at this point in the history
…ble buttons.
  • Loading branch information
teonator committed Oct 28, 2024
1 parent c2a47c1 commit 022434f
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 29 deletions.
1 change: 1 addition & 0 deletions system/config/Config.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ component {
interceptorSettings.customInterceptionPoints.append( "postGetExtraEditRecordActionButtons" );
interceptorSettings.customInterceptionPoints.append( "postExtraTopRightButtonsForEditRecord" );
interceptorSettings.customInterceptionPoints.append( "postGetExtraCloneRecordActionButtons" );
interceptorSettings.customInterceptionPoints.append( "postGetExtraSortRecordsActionButtons" );
interceptorSettings.customInterceptionPoints.append( "postExtraTopRightButtons" );
interceptorSettings.customInterceptionPoints.append( "preValidateForm" );
interceptorSettings.customInterceptionPoints.append( "preRenderLabelSelectData" );
Expand Down
83 changes: 76 additions & 7 deletions system/handlers/admin/DataManager.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -1361,18 +1361,18 @@ component extends="preside.system.base.AdminHandler" {
}

public void function sortRecords( event, rc, prc ) {
_checkPermission( argumentCollection=arguments, key="edit" );

var objectName = prc.objectName ?: "";
var objectTitle = prc.objectTitle ?: "";
var objectTitlePlural = prc.objectTitlePlural ?: "";
var getRecordsArgs = { objectName = objectName };
var getRecordsArgs = { objectName=objectName };

if ( !datamanagerService.isSortable( objectName ) ) {
messageBox.error( translateResource( uri="cms:datamanager.objectNotSortable.error", data=[ objectTitle ] ) );
setNextEvent( url=event.buildAdminLink( objectName=objectName, operation="listing" ) );
}

_checkPermission( argumentCollection=arguments, key="edit" );

customizationService.runCustomization(
objectName = objectName
, action = "preFetchRecordsForSorting"
Expand All @@ -1395,15 +1395,28 @@ component extends="preside.system.base.AdminHandler" {
}

var recordsForSorting = datamanagerService.getRecordsForSorting( argumentCollection=getRecordsArgs );
prc.records = recordsForSorting.records;
prc.ordered = recordsForSorting.ordered;

prc.records = recordsForSorting.records;
prc.ordered = recordsForSorting.ordered;
prc.renderedActionButtons = customizationService.runCustomization(
objectName = objectName
, action = "sortRecordsActionButtons"
, args = {
objectName = objectName
, recordId = prc.recordId ?: ""
, version = ( rc.version ?: "" )
, record = prc.record
}
, defaultHandler = "admin.datamanager._sortRecordsActionButtons"
);

prc.pageIcon = "sort-amount-asc";
prc.pageTitle = translateResource( uri="cms:datamanager.sortRecords.title", data=[ objectTitlePlural ] );

event.addAdminBreadCrumb(
title = translateResource( uri="cms:datamanager.sortRecords.breadcrumb.title" )
, link = ""
);
prc.pageTitle = translateResource( uri="cms:datamanager.sortRecords.title", data=[ objectTitlePlural ] );
prc.pageIcon = "sort-amount-asc";
}

public void function sortRecordsAction( event, rc, prc ) {
Expand Down Expand Up @@ -3838,6 +3851,62 @@ component extends="preside.system.base.AdminHandler" {
return args.actions;
}

private string function _sortRecordsActionButtons( event, rc, prc, args={} ) {
args.actionButtons = customizationService.runCustomization(
objectName = args.objectName ?: ""
, args = args
, action = "getSortRecordsActionButtons"
, defaultHandler = "admin.datamanager._getSortRecordsActionButtons"
);

return renderView( view="/admin/datamanager/_addOrEditRecordActionButtons", args=args );
}

private array function _getSortRecordsActionButtons( event, rc, prc, args={} ) {
var objectTitle = translateObjectName( args.objectName );

args.cancelAction = args.cancelAction ?: event.buildAdminLink( objectName=args.objectName, operation="listing" );
args.cancelLabel = args.cancelLabel ?: translateResource( "cms:datamanager.cancel.btn" );
args.resetLabel = args.resetLabel ?: translateResource( uri="cms:datamanager.sort.records.reset.btn", data=[ objectTitle ] )
args.sortLabel = args.sortLabel ?: translateResource( uri="cms:datamanager.sort.records.sort.btn", data=[ objectTitle ] );

args.actions = [
{
type = "link"
, href = args.cancelAction
, class = "btn-default"
, globalKey = "c"
, iconClass = "fa-reply"
, label = args.cancelLabel
}
,
{
type = "link"
, href = "##"
, id = "reset-order-btn "
, class = "btn-info"
, iconClass = "fa-refresh"
, label = args.resetLabel
}
,
{
type = "button"
, class = "btn-info"
, iconClass = "fa-save"
, label = args.sortLabel
}
];

customizationService.runCustomization(
objectName = args.objectName ?: ""
, args = args
, action = "getExtraAddRecordActionButtons"
);

announceInterception( "postGetExtraSortRecordsActionButtons", args );

return args.actions;
}

private string function _cloneRecordForm( event, rc, prc, args={} ) {
var objectName = args.objectName ?: "";
Expand Down
3 changes: 3 additions & 0 deletions system/i18n/cms.properties
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ datamanager.managefilters.segmentation.recalculation.log.finish=Finished recalcu
datamanager.managefilters.segmentation.clone.log.start=Cloning children of [{1}] to new filter: [{2}]...
datamanager.managefilters.segmentation.clone.log.copy.record=Copying filter [{1}]
datamanager.managefilters.segmentation.clone.log.finish=Finished cloning children of [{1}] to new filter: [{2}].
datamanager.sort.records.reset.btn=Reset order
datamanager.sort.records.sort.btn=Save order
version.navigator.old.version.message=Warning: you are viewing an old version of this {1}
version.navigator.current.version.message=You are viewing the most up to date version of this {1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="col-md-offset-2">
<cfloop array="#args.actionButtons#" item="button">
<cfif button.type == "link">
<a href="#button.href#" class="btn #( button.class ?: '' )#"<cfif Len( Trim( button.globalKey ?: '' ))> data-global-key="#button.globalKey#"</cfif>>
<a href="#button.href#" class="btn #( button.class ?: '' )#"<cfif Len( Trim( button.globalKey ?: '' ))> data-global-key="#button.globalKey#"</cfif> <cfif Len( Trim( button.id ?: '' ))> id="#button.id#"</cfif>>
<cfif Len( Trim( button.iconClass ?: "" ) )>
<i class="fa fa-fw #button.iconClass# bigger-110"></i>
</cfif>
Expand Down
30 changes: 9 additions & 21 deletions system/views/admin/datamanager/sortRecords.cfm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<!---@feature admin--->
<cfscript>
object = rc.object ?: "";
records = IsQuery( prc.records ?: "" ) ? queryToArray( prc.records ) : ( prc.records ?: [] );
ordered = prc.ordered ?: "";
formId = "sortForm-" & CreateUUId();
cancelLink = event.buildAdminLink( objectName=object, operation="listing" );
object = rc.object ?: "";
records = IsQuery( prc.records ?: "" ) ? queryToArray( prc.records ) : ( prc.records ?: [] );
ordered = prc.ordered ?: "";
formId = "sortForm-" & CreateUUID();
renderedActionButtons = prc.renderedActionButtons ?: "";
</cfscript>

<cfoutput>
<cfif !ArrayLen( records )>
<cfif not ArrayLen( records )>
<p class="alert alert-warning">
<i class="fa fa-fw fa-exclamation-triangle"></i>
#translateResource( uri="cms:datamanager.noRecordsToSort.error" )#
Expand Down Expand Up @@ -36,21 +37,8 @@
<input type="hidden" value="#object#" name="object" />
<input type="hidden" value="#ordered#" name="ordered" />

<div class="form-actions">
<div>
<a href="#cancelLink#" class="btn btn-sm btn-danger">
<i class="fa fa-reply bigger-110"></i>
#translateResource( "cms:cancel.btn" )#
</a>
<a id="reset-order-btn" class="btn btn-sm btn-default">
<i class="fa fa-reply bigger-110"></i>
#translateResource( "cms:sitetree.reorderchildren.reset.btn" )#
</a>
<button class="btn btn-sm btn-success" type="submit">
<i class="fa fa-check bigger-110"></i>
#translateResource( "cms:save.btn" )#
</button>
</div>
<div class="form-actions row">
#renderedActionButtons#
</div>
</form>
</cfif>
Expand Down

0 comments on commit 022434f

Please sign in to comment.