Skip to content

Commit

Permalink
Fix new listing actions behaviors
Browse files Browse the repository at this point in the history
- Destroy action was not removed when disabling forceDelete in indexOptions
- Duplicate action was showing in trash and was not removed when disabled in indexOptions (which is by default)
- Fix bulk destroy integration
  • Loading branch information
ifox committed Mar 23, 2020
1 parent d49df23 commit 2d1b2eb
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/assets/admin/twill-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Inter-Regular.woff": "/assets/admin/fonts/Inter-Regular.aebfbb3c.woff",
"Inter-Regular.woff2": "/assets/admin/fonts/Inter-Regular.bffaed79.woff2",
"chunk-common.css": "/assets/admin/css/chunk-common.ee1d8aaf.css",
"chunk-common.js": "/assets/admin/js/chunk-common.9fb39aa4.js",
"chunk-common.js": "/assets/admin/js/chunk-common.2031ba77.js",
"chunk-vendors.css": "/assets/admin/css/chunk-vendors.e0f3ef32.css",
"chunk-vendors.js": "/assets/admin/js/chunk-vendors.ceaa7d19.js",
"icons-files.svg": "/assets/admin/icons/icons-files.3cdbddfb2725088d.svg",
Expand All @@ -25,6 +25,6 @@
"main-form.css": "/assets/admin/css/main-form.7c11184a.css",
"main-form.js": "/assets/admin/js/main-form.771f10cf.js",
"main-free.js": "/assets/admin/js/main-free.efda4e65.js",
"main-listing.css": "/assets/admin/css/main-listing.d6d4f54d.css",
"main-listing.js": "/assets/admin/js/main-listing.a38e9b96.js"
"main-listing.css": "/assets/admin/css/main-listing.fa4de685.css",
"main-listing.js": "/assets/admin/js/main-listing.1a81c8e5.js"
}
8 changes: 5 additions & 3 deletions frontend/js/components/table/BulkEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@
published: status.published && (row.published || false),
canPublish: status.canPublish && row.hasOwnProperty('published'),
deleted: status.deleted && (row.deleted || false),
canDelete: status.canDelete && row.delete !== null
canDelete: status.canDelete && row.delete !== null,
canDestroy: status.canDestroy && row.hasOwnProperty('destroyable')
}
}, {
featured: true,
canFeature: true,
published: true,
canPublish: true,
deleted: true,
canDelete: true
canDelete: true,
canDestroy: true
})
})
},
Expand All @@ -73,7 +75,7 @@
return window[process.env.VUE_APP_NAME].CMS_URLS.bulkRestore !== '' && this.bulkStatus.deleted
},
bulkDestroyable: function () {
return window[process.env.VUE_APP_NAME].CMS_URLS.bulkDestroy !== '' && this.bulkStatus.deleted
return window[process.env.VUE_APP_NAME].CMS_URLS.bulkDestroy !== '' && this.bulkStatus.deleted && this.bulkStatus.canDestroy
},
clearBulkSelect: function () {
this.$store.commit(DATATABLE.REPLACE_DATATABLE_BULK, [])
Expand Down
10 changes: 5 additions & 5 deletions frontend/js/components/table/tableCell/TableCellActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
<a v-if="row.hasOwnProperty('featured') && !row.hasOwnProperty('deleted')"
href="#"
@click.prevent="update('featured')">{{ row['featured'] ? $trans('listing.dropdown.unfeature', 'Unfeature') : $trans('listing.dropdown.feature', 'Feature') }}</a>
<a v-if="row.duplicate && !row.hasOwnProperty('deleted')"
href="#"
@click.prevent="duplicateRow">{{ $trans('listing.dropdown.duplicate', 'Duplicate') }}</a>
<a v-if="row.hasOwnProperty('deleted')"
href="#"
@click.prevent="restoreRow">{{ $trans('listing.dropdown.restore', 'Restore') }}</a>
<a v-if="row.hasOwnProperty('deleted')"
<a v-if="row.hasOwnProperty('deleted') && row.hasOwnProperty('destroyable')"
href="#"
@click.prevent="destroyRow">{{ $trans('listing.dropdown.destroy', 'Destroy') }}</a>
<a v-else-if="row.delete"
<a v-else-if="row.delete && !row.hasOwnProperty('deleted')"
href="#"
@click.prevent="deleteRow">{{ $trans('listing.dropdown.delete', 'Delete') }}</a>
<a v-if="row.hasOwnProperty('duplicate')"
href="#"
@click.prevent="duplicateRow">{{ $trans('listing.dropdown.duplicate', 'Duplicate') }}</a>
</div>
</a17-dropdown>
</template>
Expand Down
4 changes: 3 additions & 1 deletion src/Http/Controllers/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public function duplicate($id, $submoduleId = null)
{

$item = $this->repository->getById($submoduleId ?? $id);
if ($newItem = $this->repository->duplicate($submoduleId ?? $id)) {
if ($newItem = $this->repository->duplicate($submoduleId ?? $id, $this->titleColumnKey)) {
$this->fireEvent();
activity()->performedOn($item)->log('duplicated');

Expand Down Expand Up @@ -913,6 +913,8 @@ protected function getIndexTableData($items)
'featured' => $item->{$this->featureField},
] : []) + (($this->getIndexOption('restore') && $itemIsTrashed) ? [
'deleted' => true,
] : []) + (($this->getIndexOption('forceDelete') && $itemIsTrashed) ? [
'destroyable' => true,
] : []) + ($translated ? [
'languages' => $item->getActiveLanguages(),
] : []) + $columnsData, $this->indexItemData($item));
Expand Down
9 changes: 7 additions & 2 deletions src/Repositories/ModuleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function setNewOrder($ids)
* @param mixed $id
* @return mixed
*/
public function duplicate($id)
public function duplicate($id, $titleColumnKey = 'title')
{

if (($object = $this->model->find($id)) === null) {
Expand All @@ -355,7 +355,12 @@ public function duplicate($id)
}

$revisionInput = json_decode($revision->payload, true);
$baseInput = collect($revisionInput)->only(['slug', 'languages'])->filter()->toArray();
$baseInput = collect($revisionInput)->only([
$titleColumnKey,
'slug',
'languages'
])->filter()->toArray();

$newObject = $this->create($baseInput);

$this->update($newObject->id, $revisionInput);
Expand Down

0 comments on commit 2d1b2eb

Please sign in to comment.