Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 3.3.8 #130

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 80 additions & 42 deletions inc/wizard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,58 @@ public static function constructForm($metademands_id, $metademands_data, $step,
}
});');

if ($metademands->fields['is_order'] == 0
&& !$preview
&& (!$seeform
|| (isset($options['resources_id'])
&& $options['resources_id'] > 0)
|| ($current_ticket > 0
&& ((!$meta_validated
&& $metademands->fields['can_update'] == true) ||
($meta_validated
&& $metademands->fields['can_clone'] == true))
&& Session::haveRight('plugin_metademands_updatemeta', READ)))
) {
echo "<script>
function fixButtonIndicator() {
// This function removes the 'active' class of all steps...
const use_as_step = window.metademands.use_as_step == 1;
if (use_as_step) {
x = document.getElementsByClassName('tab-step');
} else {
x = document.getElementsByClassName('tab-nostep');
}

let create = false;
if (use_as_step == 1) {
let nextTab = window.metademands.currentTab + 1;
while (nextTab < x.length && x[nextTab].firstChild.style.display == 'none') {
nextTab = nextTab + 1;
}

if (x[nextTab] != undefined) {
let bloc = x[nextTab].firstChild.getAttribute('bloc-id');
let id_bloc = parseInt(bloc.replace('bloc', ''));
if (!window.metademands.listBlock.includes(id_bloc)) {
create = true;
}
}

if (nextTab >= x.length) {
document.getElementById('nextBtn').innerHTML = window.metademands.submittitle;
// create = true;
} else {
if (create) {
document.getElementById('nextBtn').innerHTML = window.metademands.submitsteptitle;
} else {
document.getElementById('nextBtn').innerHTML = window.metademands.nextsteptitle;
}
}
}
}

</script>";
}

foreach ($allfields as $block => $line) {
if ($use_as_step == 1 && $metademands->fields['is_order'] == 0) {
Expand Down Expand Up @@ -1496,10 +1548,10 @@ public static function constructForm($metademands_id, $metademands_data, $step,
echo "</span>";
}

echo "<button type='button' id='prevBtn' class='btn btn-primary ticket-button' onclick='nextPrev(-1)'>";
echo "<button type='button' id='prevBtn' class='btn btn-primary ticket-button'>";
echo "<i class='ti ti-chevron-left'></i>&nbsp;" . __('Previous', 'metademands') . "</button>";

echo "&nbsp;<button type='button' id='nextBtn' class='btn btn-primary ticket-button' onclick='nextPrev(1)'>";
echo "&nbsp;<button type='button' id='nextBtn' class='btn btn-primary ticket-button'>";
echo __('Next', 'metademands') . "&nbsp;<i class='ti ti-chevron-right'></i></button>";


Expand Down Expand Up @@ -1756,6 +1808,32 @@ static function validateScript($params)
}
echo "<script>
$(document).ready(function (){
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
prevBtn.addEventListener('click', () => nextPrev(-1));
nextBtn.addEventListener('click', () => nextPrev(1));

window.metademands = {};
window.metademands.nexttitle = '$nexttitle';
window.metademands.submittitle = '$submittitle';
window.metademands.submitmsg = '$submitmsg';
window.metademands.use_as_step = '$use_as_step';
window.metademands.nextsteptitle = '$nextsteptitle';
window.metademands.submitsteptitle = '$submitsteptitle';
window.metademands.submitstepmsg = '$submitstepmsg';
window.metademands.seesummary = '$see_summary';
window.metademands.hiddenblocs = {$json_hidden_blocks};
window.metademands.msg = '$alert';
window.metademands.all_meta_fields = {$json_all_meta_fields};
window.metademands.firstnumTab = 0;
window.metademands.currentTab = 0; // Current tab is set to be the first tab (0)
window.metademands.use_condition = '$use_condition';
window.metademands.show_button = 1;
window.metademands.show_rule = '$show_rule';
window.metademands.nexthref = '$nexthref';
window.metademands.use_richtext = '$use_richtext';
window.metademands.richtext_ids = {$richtext_id};

var nexttitle = '$nexttitle';
var submittitle = '$submittitle';
var submitmsg = '$submitmsg';
Expand Down Expand Up @@ -2504,46 +2582,6 @@ function fixStepIndicator(n) {
});
});
}

function fixButtonIndicator() {
// This function removes the 'active' class of all steps...
if (use_as_step == 1) {
var x = document.getElementsByClassName('tab-step');
} else {
var x = document.getElementsByClassName('tab-nostep');
}

create = false;
if (use_as_step == 1) {
nextTab = currentTab + 1;
while (nextTab < x.length && x[nextTab].firstChild.style.display == 'none') {
nextTab = nextTab + 1;
}

var listBlock = [" . implode(",", $list_blocks) . "];

if(x[nextTab] != undefined) {
bloc = x[nextTab].firstChild.getAttribute('bloc-id');
id_bloc = parseInt(bloc.replace('bloc',''));
if(!listBlock.includes(id_bloc)) {
create = true;
}
}

if(nextTab >= x.length) {
document.getElementById('nextBtn').innerHTML = submittitle;
// create = true;
} else {
if(create) {
document.getElementById('nextBtn').innerHTML = submitsteptitle;
// document.getElementById('nextMsg').style.display = 'block';
// document.getElementById('nextMsg').innerHTML = submitstepmsg;
} else {
document.getElementById('nextBtn').innerHTML = nextsteptitle;
}
}
}
}
});
</script>";
}
Expand Down