| @@ 1528-1533 (lines=6) @@ | ||
| 1525 | $actions = $record->getCMSActions(); |
|
| 1526 | // add default actions if none are defined |
|
| 1527 | if(!$actions || !$actions->count()) { |
|
| 1528 | if($record->hasMethod('canEdit') && $record->canEdit()) { |
|
| 1529 | $actions->push( |
|
| 1530 | FormAction::create('save',_t('CMSMain.SAVE','Save')) |
|
| 1531 | ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') |
|
| 1532 | ); |
|
| 1533 | } |
|
| 1534 | if($record->hasMethod('canDelete') && $record->canDelete()) { |
|
| 1535 | $actions->push( |
|
| 1536 | FormAction::create('delete',_t('ModelAdmin.DELETE','Delete')) |
|
| @@ 1534-1539 (lines=6) @@ | ||
| 1531 | ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') |
|
| 1532 | ); |
|
| 1533 | } |
|
| 1534 | if($record->hasMethod('canDelete') && $record->canDelete()) { |
|
| 1535 | $actions->push( |
|
| 1536 | FormAction::create('delete',_t('ModelAdmin.DELETE','Delete')) |
|
| 1537 | ->addExtraClass('ss-ui-action-destructive') |
|
| 1538 | ); |
|
| 1539 | } |
|
| 1540 | } |
|
| 1541 | } |
|
| 1542 | ||
| @@ 51-64 (lines=14) @@ | ||
| 48 | ||
| 49 | // Unpublish action |
|
| 50 | $isPublished = $record->isPublished(); |
|
| 51 | if($isPublished && $record->canUnpublish()) { |
|
| 52 | $actions->push( |
|
| 53 | FormAction::create( |
|
| 54 | 'doUnpublish', |
|
| 55 | _t('VersionedGridFieldItemRequest.BUTTONUNPUBLISH', 'Unpublish') |
|
| 56 | ) |
|
| 57 | ->setUseButtonTag(true) |
|
| 58 | ->setDescription(_t( |
|
| 59 | 'VersionedGridFieldItemRequest.BUTTONUNPUBLISHDESC', |
|
| 60 | 'Remove this record from the published site' |
|
| 61 | )) |
|
| 62 | ->addExtraClass('ss-ui-action-destructive') |
|
| 63 | ); |
|
| 64 | } |
|
| 65 | ||
| 66 | // Archive action |
|
| 67 | if($record->canArchive()) { |
|
| @@ 67-80 (lines=14) @@ | ||
| 64 | } |
|
| 65 | ||
| 66 | // Archive action |
|
| 67 | if($record->canArchive()) { |
|
| 68 | // Replace "delete" action |
|
| 69 | $actions->removeByName('action_doDelete'); |
|
| 70 | ||
| 71 | // "archive" |
|
| 72 | $actions->push( |
|
| 73 | FormAction::create('doArchive', _t('VersionedGridFieldItemRequest.ARCHIVE','Archive')) |
|
| 74 | ->setDescription(_t( |
|
| 75 | 'VersionedGridFieldItemRequest.BUTTONARCHIVEDESC', |
|
| 76 | 'Unpublish and send to archive' |
|
| 77 | )) |
|
| 78 | ->addExtraClass('delete ss-ui-action-destructive') |
|
| 79 | ); |
|
| 80 | } |
|
| 81 | return $actions; |
|
| 82 | } |
|
| 83 | ||