WIP: Backup upload

This commit is contained in:
Jose Gonzalez 2020-03-23 15:16:54 +01:00
parent 28cdbf1409
commit c18d339730
2 changed files with 34 additions and 17 deletions

View File

@ -73,10 +73,13 @@ if (is_ajax()) {
$manageBlock->run(); $manageBlock->run();
// Get the id_np. // Get the id_np.
$id_np = $manageBlock->getIdNp(); $id_np = $manageBlock->getIdNp();
$saveData = $manageBlock->getSaveData();
// Show the proper window. if ($saveData === true) {
if ($id_np === -1) { // Save the data sent
// List all Module Block. $manageBlock->saveData();
} else if ($id_np === -1) {
// List all Module Blocks.
$manageBlock->moduleBlockList(); $manageBlock->moduleBlockList();
} else { } else {
// Create new o update Template. // Create new o update Template.
@ -88,7 +91,7 @@ if (is_ajax()) {
<script> <script>
$(document).ready (function () { $(document).ready (function () {
//Close button //Close button
$("[id*=checkbox-active]").click (function () { $("[id*=checkbox-switch]").click (function () {
$("[id*=checkbox-block_id]").toggleClass('alpha50'); $("[id*=checkbox-block_id]").toggleClass('alpha50');
}); });
}); });

View File

@ -120,7 +120,7 @@ class ManageBlock extends HTML
$this->pen = get_parameter('pen', ''); $this->pen = get_parameter('pen', '');
$this->offset = get_parameter('offset', 0); $this->offset = get_parameter('offset', 0);
$this->ajaxController = $ajax_controller; $this->ajaxController = $ajax_controller;
$this->saveData = (bool) get_parameter('save', 0);
return $this; return $this;
} }
@ -184,12 +184,23 @@ class ManageBlock extends HTML
} }
/**
* Get the value of if we want save the changes
*
* @return boolean True if must save the changes
*/
public function getSaveData()
{
return $this->saveData;
}
/** /**
* Undocumented function * Undocumented function
* *
* @return void * @return void
*/ */
private function manageData() private function saveData()
{ {
// if ($) // if ($)
$name = get_parameter('name', ''); $name = get_parameter('name', '');
@ -368,6 +379,8 @@ class ManageBlock extends HTML
// Inputs. // Inputs.
$inputs = []; $inputs = [];
// Inputs.
$rawInputs = '';
$inputs[] = [ $inputs[] = [
'label' => __('Name'), 'label' => __('Name'),
@ -420,15 +433,6 @@ class ManageBlock extends HTML
$js = '$(\'#text-pen\').tagEditor();'; $js = '$(\'#text-pen\').tagEditor();';
$this->printFormAsList(
[
'form' => $form,
'inputs' => $inputs,
'js' => $js,
true
]
);
if ($createNewBlock === false) { if ($createNewBlock === false) {
// Get the data. // Get the data.
$sql = sprintf( $sql = sprintf(
@ -503,13 +507,13 @@ class ManageBlock extends HTML
$data[1] = ui_print_moduletype_icon($module['type'], true); $data[1] = ui_print_moduletype_icon($module['type'], true);
$data[2] = mb_strimwidth(io_safe_output($module['description']), 0, 150, '...'); $data[2] = mb_strimwidth(io_safe_output($module['description']), 0, 150, '...');
$data[3] = html_print_checkbox_switch_extended('switch_'.$id_group.'_'.$module['component_id'], 1, 0, false, 'switchBlockControl(event)', '', true); $data[3] = html_print_checkbox_switch_extended('switch_'.$id_group.'_'.$module['component_id'], 1, 0, false, 'switchBlockControl(event)', '', true);
// $data[3] .= html_print_input_hidden();
array_push($table->data, $data); array_push($table->data, $data);
} }
$content = html_print_table($table, true); $content = html_print_table($table, true);
ui_toggle($content, $blockTitle, '', '', false); $rawInputs .= ui_toggle($content, $blockTitle, '', '', false, true);
} }
} }
} else { } else {
@ -517,6 +521,16 @@ class ManageBlock extends HTML
} }
} }
$this->printFormAsList(
[
'form' => $form,
'inputs' => $inputs,
'rawInputs' => $rawInputs,
'js' => $js,
true
]
);
$javascript = " $javascript = "
<script> <script>
function switchBlockControl(e){ function switchBlockControl(e){