Gitlab CSE Unil

Commit a5364bd7 authored by M. Chardon's avatar M. Chardon
Browse files

optimisation worskpace et sécurité sur suppression

parent 824165fd
This diff is collapsed.
...@@ -162,6 +162,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -162,6 +162,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html(""); $('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide(); $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', 'disabled');
var params = {}; var params = {};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisadd', contextid, params) fragment.loadFragment('assignfeedback_editpdfplus', 'axisadd', contextid, params)
.done(function (html, js) { .done(function (html, js) {
...@@ -176,6 +177,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -176,6 +177,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html(""); $('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide(); $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', 'disabled');
/*var context = {name: 'Tweety bird', intelligence: 2}; /*var context = {name: 'Tweety bird', intelligence: 2};
templates.render('assignfeedback_editpdfplus/admin_axis_add', context) templates.render('assignfeedback_editpdfplus/admin_axis_add', context)
// It returns a promise that needs to be resoved. // It returns a promise that needs to be resoved.
...@@ -195,18 +197,22 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -195,18 +197,22 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
}; };
// //
AdminPanel.prototype.openDivDelAxis = function () { AdminPanel.prototype.openDivDelAxis = function () {
$("#axistool").hide(); var canBeDelete = $("#editpdlplus_axes option:selected").data('delete');
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis').show(); if (canBeDelete !== null && parseInt(canBeDelete) === 0) {
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body').html(""); $("#axistool").hide();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide(); $('#assignfeedback_editpdfplus_widget_admin_div_delaxis').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide(); $('#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body').html("");
var axeid = $("#editpdlplus_axes option:selected").val(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
var params = {axeid: axeid}; $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
fragment.loadFragment('assignfeedback_editpdfplus', 'axisdel', contextid, params) $("#editpdlplus_axes").prop('disabled', 'disabled');
.done(function (html, js) { var axeid = $("#editpdlplus_axes option:selected").val();
templates.appendNodeContents('#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body', var params = {axeid: axeid};
html, js); fragment.loadFragment('assignfeedback_editpdfplus', 'axisdel', contextid, params)
}.bind(this)).fail(notification.exception); .done(function (html, js) {
templates.appendNodeContents('#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body',
html, js);
}.bind(this)).fail(notification.exception);
}
}; };
/** /**
* Fade the dom node out, update it, and fade it back. * Fade the dom node out, update it, and fade it back.
...@@ -358,46 +364,54 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -358,46 +364,54 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
args: {jsonformdata: JSON.stringify(data)} args: {jsonformdata: JSON.stringify(data)}
} }
])[0].done(function (toolbar) { ])[0].done(function (toolbar) {
if (toolbar[0].message === "") { if (toolbar[0].message === "" || toolbar[0].message === "1") {
//mise à jour du message //mise à jour du message
$("#message_edit_tool").html(toolbar[0].messageok); $("#message_edit_tool").html(toolbar[0].messageok);
$("#message_edit_tool").addClass("alert-success"); $("#message_edit_tool").addClass("alert-success");
$("#message_edit_tool").removeClass("alert-danger"); $("#message_edit_tool").removeClass("alert-danger");
//mise à jour bar d'outils //mise à jour bar d'outils
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html(""); $("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
for (var i = 0; i < toolbar.length; i++) { if (parseInt(toolbar[0].toolid) > 0) {
var classButton = "btn-default"; for (var i = 0; i < toolbar.length; i++) {
if (toolbar[i].enable !== 1) { var classButton = "btn-default";
classButton = ""; if (toolbar[i].enable !== 1) {
} classButton = "";
if (toolbar[i].toolid === toolbar[i].selecttool) { }
classButton = "btn-primary"; if (toolbar[i].toolid === toolbar[i].selecttool) {
} classButton = "btn-primary";
var style = "";
if (toolbar[i].typetool === 4 || toolbar[i].typetool === 1) {
style = "text-decoration: underline;";
}
var label = toolbar[i].button;
if (toolbar[i].typetool === 4 || toolbar[i].typetool === 5) {
label = "| " + label;
if (toolbar[i].typetool === 4) {
label += " |";
} }
var style = "";
if (toolbar[i].typetool === 4 || toolbar[i].typetool === 1) {
style = "text-decoration: underline;";
}
var label = toolbar[i].button;
if (toolbar[i].typetool === 4 || toolbar[i].typetool === 5) {
label = "| " + label;
if (toolbar[i].typetool === 4) {
label += " |";
}
}
var buttonTmp = "<button class='btn "
+ classButton
+ " editpdlplus_tool' id='editpdlplus_tool_"
+ toolbar[i].toolid + "' style='"
+ style
+ "' value='"
+ toolbar[i].toolid
+ "' data-enable='"
+ toolbar[i].enable + "'>"
+ label
+ "</button>";
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
} }
var buttonTmp = "<button class='btn " $(".editpdlplus_tool").on("click", refreshToolView);
+ classButton } else {
+ " editpdlplus_tool' id='editpdlplus_tool_" var axeid = toolbar[0].axeid;
+ toolbar[i].toolid + "' style='" var axeOption = $("#editpdlplus_axes option[value='" + axeid + "']");
+ style axeOption.data('delete', 0);
+ "' value='" var btr = $("#assignfeedback_editpdfplus_widget_admin_button_delaxis");
+ toolbar[i].toolid btr.removeClass("disabled");
+ "' data-enable='"
+ toolbar[i].enable + "'>"
+ label
+ "</button>";
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
} }
$(".editpdlplus_tool").on("click", refreshToolView);
$('#toolworkspace').html(""); $('#toolworkspace').html("");
} else { } else {
$("#message_edit_tool").html(toolbar[0].message); $("#message_edit_tool").html(toolbar[0].message);
...@@ -510,6 +524,11 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -510,6 +524,11 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
} }
$(".editpdlplus_tool").on("click", refreshToolView); $(".editpdlplus_tool").on("click", refreshToolView);
$('#toolworkspace').html(""); $('#toolworkspace').html("");
var axeid = toolbar[0].axeid;
var axeOption = $("#editpdlplus_axes option[value='" + axeid + "']");
axeOption.data('delete', 1);
var delAxBt = $("#assignfeedback_editpdfplus_widget_admin_button_delaxis");
delAxBt.addClass("disabled");
} else { } else {
$("#message_edit_tool").html(toolbar[0].message); $("#message_edit_tool").html(toolbar[0].message);
$("#message_edit_tool").addClass("alert-danger"); $("#message_edit_tool").addClass("alert-danger");
......
...@@ -397,8 +397,12 @@ class assignfeedback_editpdfplus_external extends external_api { ...@@ -397,8 +397,12 @@ class assignfeedback_editpdfplus_external extends external_api {
if (admin_editor::del_tool($customdata, $context->id)) { if (admin_editor::del_tool($customdata, $context->id)) {
$res = array(); $res = array();
$tools = admin_editor::get_tools_by_axis($axisid); $tools = admin_editor::get_tools_by_axis($axisid);
foreach ($tools as $toolTmp) { if (sizeof($tools) > 0) {
$res[] = array('axeid' => $axisid, 'selecttool' => $tool->id, 'enable' => $toolTmp->enabled, 'toolid' => $toolTmp->id, 'typetool' => $toolTmp->type, 'button' => $toolTmp->label, 'message' => '', 'messageok' => get_string('admindeltool_messageok', 'assignfeedback_editpdfplus')); foreach ($tools as $toolTmp) {
$res[] = array('axeid' => $axisid, 'selecttool' => $tool->id, 'enable' => $toolTmp->enabled, 'toolid' => $toolTmp->id, 'typetool' => $toolTmp->type, 'button' => $toolTmp->label, 'message' => '', 'messageok' => get_string('admindeltool_messageok', 'assignfeedback_editpdfplus'));
}
} else {
$res[] = array('axeid' => $axisid, 'selecttool' => -1, 'toolid' => -1, 'message' => '1', 'messageok' => get_string('admindeltool_messageok', 'assignfeedback_editpdfplus'));
} }
return $res; return $res;
} else { } else {
...@@ -417,10 +421,10 @@ class assignfeedback_editpdfplus_external extends external_api { ...@@ -417,10 +421,10 @@ class assignfeedback_editpdfplus_external extends external_api {
array( array(
'axeid' => new external_value(PARAM_INT, 'axe id'), 'axeid' => new external_value(PARAM_INT, 'axe id'),
'selecttool' => new external_value(PARAM_INT, 'tool id'), 'selecttool' => new external_value(PARAM_INT, 'tool id'),
'enable' => new external_value(PARAM_INT, 'tool enable'), 'enable' => new external_value(PARAM_INT, 'tool enable', VALUE_OPTIONAL),
'toolid' => new external_value(PARAM_INT, 'tool id'), 'toolid' => new external_value(PARAM_INT, 'tool id'),
'typetool' => new external_value(PARAM_INT, 'tool type'), 'typetool' => new external_value(PARAM_INT, 'tool type', VALUE_OPTIONAL),
'button' => new external_value(PARAM_TEXT, 'tool label'), 'button' => new external_value(PARAM_TEXT, 'tool label', VALUE_OPTIONAL),
'message' => new external_value(PARAM_TEXT, 'message', VALUE_OPTIONAL), 'message' => new external_value(PARAM_TEXT, 'message', VALUE_OPTIONAL),
'messageok' => new external_value(PARAM_TEXT, 'messageok', VALUE_OPTIONAL) 'messageok' => new external_value(PARAM_TEXT, 'messageok', VALUE_OPTIONAL)
) )
......
...@@ -45,15 +45,6 @@ ...@@ -45,15 +45,6 @@
</button> </button>
</div> </div>
</div> </div>
<div id="assignfeedback_editpdfplus_widget_admin_div_addaxis">
<div class="panel-body"></div>
</div>
<div id="assignfeedback_editpdfplus_widget_admin_div_editaxis">
<div class="panel-body"></div>
</div>
<div id="assignfeedback_editpdfplus_widget_admin_div_delaxis">
<div class="panel-body"></div>
</div>
</div> </div>
<div class='col-sm-10' id='assignfeedback_editpdfplus_widget_admin_toolworkspace'> <div class='col-sm-10' id='assignfeedback_editpdfplus_widget_admin_toolworkspace'>
<div id='editpdlplus_toolbars'> <div id='editpdlplus_toolbars'>
...@@ -71,6 +62,17 @@ ...@@ -71,6 +62,17 @@
<div id="editpdlplus_tool_item" style="margin-top: 10px;"></div> <div id="editpdlplus_tool_item" style="margin-top: 10px;"></div>
</div> </div>
<div class='col-sm-10'>
<div id="assignfeedback_editpdfplus_widget_admin_div_addaxis" style="display:none;">
<div class="panel-body"></div>
</div>
<div id="assignfeedback_editpdfplus_widget_admin_div_editaxis" style="display:none;">
<div class="panel-body"></div>
</div>
<div id="assignfeedback_editpdfplus_widget_admin_div_delaxis" style="display:none;">
<div class="panel-body"></div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -36,6 +36,7 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification ...@@ -36,6 +36,7 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification
$("#axistool").show(); $("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show(); $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
}).fail(notification.exception); }).fail(notification.exception);
}); });
$("#axisDelCancel").on("click", function () { $("#axisDelCancel").on("click", function () {
...@@ -43,6 +44,7 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification ...@@ -43,6 +44,7 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification
$("#axistool").show(); $("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show(); $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
}); });
}); });
{{/ js }} {{/ js }}
\ No newline at end of file
...@@ -28,28 +28,34 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification ...@@ -28,28 +28,34 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification
var divAxis = "<div id='editpdlplus_toolbar_"+axe[0].axeid+"' class='btn-group toolbar' style='display: none;'></div>"; var divAxis = "<div id='editpdlplus_toolbar_"+axe[0].axeid+"' class='btn-group toolbar' style='display: none;'></div>";
$('#editpdlplus_toolbars').append(divAxis); $('#editpdlplus_toolbars').append(divAxis);
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html(""); $('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis').hide();
var option=new Option(axe[0].axelabel, axe[0].axeid, true, true); var option=new Option(axe[0].axelabel, axe[0].axeid, true, true);
$("#editpdlplus_axes").append(option); $("#editpdlplus_axes").append(option);
$("#editpdlplus_axes").change(); $("#editpdlplus_axes").change();
$('#editpdlplus_tool_item').html(""); $('#editpdlplus_tool_item').html("");
} else { } else {
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html(""); $('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis').hide();
$("#editpdlplus_axes option:selected").html(axe[0].axelabel); $("#editpdlplus_axes option:selected").html(axe[0].axelabel);
} }
$("#axistool").show(); $("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show(); $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
}).fail(notification.exception); }).fail(notification.exception);
}); });
$("#axisFormCancel").on("click", function () { $("#axisFormCancel").on("click", function () {
if ('{{action}}' === 'add'){ if ('{{action}}' === 'add'){
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html(""); $('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis').hide();
} else { } else {
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html(""); $('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis').hide();
} }
$("#axistool").show(); $("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show(); $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
}); });
}); });
{{/ js }} {{/ js }}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment