fix: [metaTemplate] Repaired update_all
parent
02cc0c30a3
commit
fa364c2b2f
|
@ -61,6 +61,35 @@ class MetaTemplatesController extends AppController
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public function updateAllTemplates()
|
||||||
|
{
|
||||||
|
if ($this->request->is('post')) {
|
||||||
|
$result = $this->MetaTemplates->updateAllTemplates();
|
||||||
|
if ($this->ParamHandler->isRest()) {
|
||||||
|
return $this->RestResponse->viewData($result, 'json');
|
||||||
|
} else {
|
||||||
|
if ($result['success']) {
|
||||||
|
$message = __n('{0} templates updated.', 'The template has been updated.', empty($template_id), $result['files_processed']);
|
||||||
|
} else {
|
||||||
|
$message = __n('{0} templates could not be updated.', 'The template could not be updated.', empty($template_id), $result['files_processed']);
|
||||||
|
}
|
||||||
|
$this->CRUD->setResponseForController('updateAllTemplate', $result['success'], $message, $result['files_processed'], $result['update_errors'], ['redirect' => $this->referer()]);
|
||||||
|
$responsePayload = $this->CRUD->getResponsePayload();
|
||||||
|
if (!empty($responsePayload)) {
|
||||||
|
return $responsePayload;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!$this->ParamHandler->isRest()) {
|
||||||
|
$this->set('title', __('Update All Meta Templates'));
|
||||||
|
$this->set('question', __('Are you sure you wish to update all the Meta Template definitions'));
|
||||||
|
$templatesUpdateStatus = $this->MetaTemplates->getUpdateStatusForTemplates();
|
||||||
|
$this->set('templatesUpdateStatus', $templatesUpdateStatus);
|
||||||
|
$this->render('updateAll');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the provided template or all templates
|
* Update the provided template or all templates
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,6 +6,7 @@ $modalType = 'confirm';
|
||||||
$modalSize = 'lg';
|
$modalSize = 'lg';
|
||||||
|
|
||||||
$tableHtml = '<table class="table"><thead><tr>';
|
$tableHtml = '<table class="table"><thead><tr>';
|
||||||
|
$tableHtml .= sprintf('<th class="text-nowrap">%s</th>', __('ID'));
|
||||||
$tableHtml .= sprintf('<th class="text-nowrap">%s</th>', __('Template'));
|
$tableHtml .= sprintf('<th class="text-nowrap">%s</th>', __('Template'));
|
||||||
$tableHtml .= sprintf('<th class="text-nowrap">%s</th>', __('Version'));
|
$tableHtml .= sprintf('<th class="text-nowrap">%s</th>', __('Version'));
|
||||||
$tableHtml .= sprintf('<th class="text-nowrap">%s</th>', __('New Template'));
|
$tableHtml .= sprintf('<th class="text-nowrap">%s</th>', __('New Template'));
|
||||||
|
@ -17,6 +18,14 @@ $numberOfUpdates = 0;
|
||||||
$numberOfSkippedUpdates = 0;
|
$numberOfSkippedUpdates = 0;
|
||||||
foreach ($templatesUpdateStatus as $uuid => $status) {
|
foreach ($templatesUpdateStatus as $uuid => $status) {
|
||||||
$tableHtml .= '<tr>';
|
$tableHtml .= '<tr>';
|
||||||
|
if (!empty($status['new'])) {
|
||||||
|
$tableHtml .= sprintf('<td>%s</td>', __('N/A'));
|
||||||
|
} else {
|
||||||
|
$tableHtml .= sprintf('<td><a href="%s">%s</a></td>',
|
||||||
|
Router::url(['controller' => 'MetaTemplates', 'action' => 'view', 'plugin' => null, h($status['existing_template']->id)]),
|
||||||
|
h($status['existing_template']->id)
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!empty($status['new'])) {
|
if (!empty($status['new'])) {
|
||||||
$tableHtml .= sprintf('<td>%s</td>', h($uuid));
|
$tableHtml .= sprintf('<td>%s</td>', h($uuid));
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +62,10 @@ foreach ($templatesUpdateStatus as $uuid => $status) {
|
||||||
if (!empty($status['new'])) {
|
if (!empty($status['new'])) {
|
||||||
$tableHtml .= sprintf('<td>%s</td>', $this->Bootstrap->icon('check', ['class' => 'text-success']));
|
$tableHtml .= sprintf('<td>%s</td>', $this->Bootstrap->icon('check', ['class' => 'text-success']));
|
||||||
} else {
|
} else {
|
||||||
if (!empty($status['new']) || !empty($status['automatically-updateable'])) {
|
// Depends on the strategy used by the update_all function. Right now, every update create a brand new template
|
||||||
|
// leaving existing data untouched. So regardless of the conflict, the new template will be created
|
||||||
|
// if (!empty($status['new']) || !empty($status['automatically-updateable'])) {
|
||||||
|
if (!empty($status['new']) || empty($status['up-to-date'])) {
|
||||||
$numberOfUpdates += 1;
|
$numberOfUpdates += 1;
|
||||||
$tableHtml .= sprintf('<td>%s</td>', $this->Bootstrap->icon('check', ['class' => 'text-success']));
|
$tableHtml .= sprintf('<td>%s</td>', $this->Bootstrap->icon('check', ['class' => 'text-success']));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue