Skip to content

Commit

Permalink
feat(Wizard) add Mapping possibility after masscreate
Browse files Browse the repository at this point in the history
  • Loading branch information
denaldhushi committed Mar 14, 2023
1 parent 5da812e commit 1d23c69
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
31 changes: 19 additions & 12 deletions include/js/wizard.js
Expand Up @@ -422,6 +422,7 @@ class WizardComponent {
}
break;
default:
this.CloseModal();
}
}

Expand Down Expand Up @@ -512,7 +513,7 @@ class WizardComponent {
/**
* Filter rows for specific IDS.
*/
FilterDataForStep() {
FilterDataForStep(ids = {}) {
if (this.WizardMode[this.ActiveStep].includes('CREATE')) {
return false;
}
Expand All @@ -524,6 +525,7 @@ class WizardComponent {
filterrows: true,
step: wizard.ActiveStep,
showdata: true,
forids: JSON.stringify(ids)
});
setTimeout(function () {
wizard.WizardInstance[`wzgrid${wizard.ActiveStep}`].setPerPage(parseInt(20));
Expand Down Expand Up @@ -1210,7 +1212,7 @@ class WizardComponent {
});
this.WizardInstance[`wzgrid${this.ActiveStep+1}`].setPerPage(parseInt(20));
}
if (operation == 'MASSCREATE' && this.steps-2 == this.ActiveStep) {
if (operation == 'MASSCREATE' && this.WizardMode[this.ActiveStep+1] == 'Mapping') {
this.Mapping(0, 1);
return true;
}
Expand All @@ -1231,7 +1233,7 @@ class WizardComponent {
this.GroupData = groupBy;
this.TreeGrid();
}
if (this.steps-1 == this.ActiveStep && type == 'next') {//mass create in last step
if (this.WizardMode[this.ActiveStep] == 'Mapping' && type == 'next') {//mass create in last step
this.MassCreate(operation);
}
return true;
Expand Down Expand Up @@ -1325,19 +1327,24 @@ class WizardComponent {
const url = `${this.url}&wizardaction=MassCreate&formodule=${this.MCModule}&subaction=${this.WizardMode[0]}`;
this.Request(url, 'post', filterData).then(function (response) {
if (response) {
wizard.FilterDataForStep(response);
ldsNotification.show(alert_arr.LBL_SUCCESS, alert_arr.LBL_CREATED_SUCCESS, 'success');
if (wizard.isModal) {
RLInstance[wizard.gridInstance].readData(1);
ldsModal.close();
wizard.ActiveStep = 0;
wizard.CheckedRows = [];
wizard.GridData = [];
wizard.GroupData = [];
localStorage.removeItem('currentWizardActive');
if (wizard.steps == wizard.ActiveStep) {
ldsModal.close();
wizard.ActiveStep = 0;
wizard.CheckedRows = [];
wizard.GridData = [];
wizard.GroupData = [];
localStorage.removeItem('currentWizardActive');
}
} else {
setTimeout(function () {
location.reload(true);
}, 1000);
if (wizard.steps == wizard.ActiveStep) {
setTimeout(function () {
location.reload(true);
}, 1000);
}
}
} else {
ldsNotification.show(alert_arr.ERROR, alert_arr.LBL_WRONG, 'error');
Expand Down
17 changes: 12 additions & 5 deletions modules/Vtiger/WizardClass.php
Expand Up @@ -299,10 +299,13 @@ public function Grid() {
$qg->setFields(array('*'));
$newRecords = $this->GetSession($current_user->id);
if ($filterrows) {
//filter records for the next step based on some givend ids
//filter records for the next step based on some given ids
if (!empty($forids)) {
$qg->startGroup();
foreach ($forids as $id) {
if (strpos($id, 'x') !== false) {
list($wsid,$id) = explode('x', $id);
}
$qg->addCondition('id', $id, 'e', 'or');
}
$qg->endGroup();
Expand Down Expand Up @@ -570,8 +573,8 @@ public function MassCreate($target = array()) {
if (!empty($subaction)) {
$target = $this->$subaction();
}
if ($target == '__MassCreateSuccess__') {
return true;
if (is_array($target)) {
return $target;
}
if (!empty($target)) {
$response = MassCreate($target, $current_user);
Expand Down Expand Up @@ -659,9 +662,13 @@ public function CreateRecords() {
$row[$fieldname] = $relid;
}
}
vtws_create($createmodule, $row, $current_user);
$rs = vtws_create($createmodule, $row, $current_user);
$createdids[] = isset($rs['id']) ? $rs['id'] : 0;
}
return '__MassCreateSuccess__';
if (isset($createdids)) {
return $createdids;
}
return false;
}
}
return false;
Expand Down

0 comments on commit 1d23c69

Please sign in to comment.