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
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', 'disabled');
var params = {};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisadd', contextid, params)
.done(function (html, js) {
......@@ -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_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', 'disabled');
/*var context = {name: 'Tweety bird', intelligence: 2};
templates.render('assignfeedback_editpdfplus/admin_axis_add', context)
// It returns a promise that needs to be resoved.
......@@ -195,18 +197,22 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
};
//
AdminPanel.prototype.openDivDelAxis = function () {
$("#axistool").hide();
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis').show();
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
var axeid = $("#editpdlplus_axes option:selected").val();
var params = {axeid: axeid};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisdel', contextid, params)
.done(function (html, js) {
templates.appendNodeContents('#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body',
html, js);
}.bind(this)).fail(notification.exception);
var canBeDelete = $("#editpdlplus_axes option:selected").data('delete');
if (canBeDelete !== null && parseInt(canBeDelete) === 0) {
$("#axistool").hide();
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis').show();
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', 'disabled');
var axeid = $("#editpdlplus_axes option:selected").val();
var params = {axeid: axeid};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisdel', contextid, params)
.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.
......@@ -358,46 +364,54 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
args: {jsonformdata: JSON.stringify(data)}
}
])[0].done(function (toolbar) {
if (toolbar[0].message === "") {
if (toolbar[0].message === "" || toolbar[0].message === "1") {
//mise à jour du message
$("#message_edit_tool").html(toolbar[0].messageok);
$("#message_edit_tool").addClass("alert-success");
$("#message_edit_tool").removeClass("alert-danger");
//mise à jour bar d'outils
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
for (var i = 0; i < toolbar.length; i++) {
var classButton = "btn-default";
if (toolbar[i].enable !== 1) {
classButton = "";
}
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 += " |";
if (parseInt(toolbar[0].toolid) > 0) {
for (var i = 0; i < toolbar.length; i++) {
var classButton = "btn-default";
if (toolbar[i].enable !== 1) {
classButton = "";
}
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 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 "
+ 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);
$(".editpdlplus_tool").on("click", refreshToolView);
} else {
var axeid = toolbar[0].axeid;
var axeOption = $("#editpdlplus_axes option[value='" + axeid + "']");
axeOption.data('delete', 0);
var btr = $("#assignfeedback_editpdfplus_widget_admin_button_delaxis");
btr.removeClass("disabled");
}
$(".editpdlplus_tool").on("click", refreshToolView);
$('#toolworkspace').html("");
} else {
$("#message_edit_tool").html(toolbar[0].message);
......@@ -510,6 +524,11 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
}
$(".editpdlplus_tool").on("click", refreshToolView);
$('#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 {
$("#message_edit_tool").html(toolbar[0].message);
$("#message_edit_tool").addClass("alert-danger");
......
......@@ -397,8 +397,12 @@ class assignfeedback_editpdfplus_external extends external_api {
if (admin_editor::del_tool($customdata, $context->id)) {
$res = array();
$tools = admin_editor::get_tools_by_axis($axisid);
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'));
if (sizeof($tools) > 0) {
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;
} else {
......@@ -417,10 +421,10 @@ class assignfeedback_editpdfplus_external extends external_api {
array(
'axeid' => new external_value(PARAM_INT, 'axe 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'),
'typetool' => new external_value(PARAM_INT, 'tool type'),
'button' => new external_value(PARAM_TEXT, 'tool label'),
'typetool' => new external_value(PARAM_INT, 'tool type', VALUE_OPTIONAL),
'button' => new external_value(PARAM_TEXT, 'tool label', VALUE_OPTIONAL),
'message' => new external_value(PARAM_TEXT, 'message', VALUE_OPTIONAL),
'messageok' => new external_value(PARAM_TEXT, 'messageok', VALUE_OPTIONAL)
)
......
......@@ -45,15 +45,6 @@
</button>
</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 class='col-sm-10' id='assignfeedback_editpdfplus_widget_admin_toolworkspace'>
<div id='editpdlplus_toolbars'>
......@@ -71,6 +62,17 @@
<div id="editpdlplus_tool_item" style="margin-top: 10px;"></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>
......
......@@ -36,6 +36,7 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification
$("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
}).fail(notification.exception);
});
$("#axisDelCancel").on("click", function () {
......@@ -43,6 +44,7 @@ require(['jquery','core/ajax','core/notification'], function($,ajax,notification
$("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
});
});
{{/ js }}
\ No newline at end of file
......@@ -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>";
$('#editpdlplus_toolbars').append(divAxis);
$('#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);
$("#editpdlplus_axes").append(option);
$("#editpdlplus_axes").change();
$('#editpdlplus_tool_item').html("");
} else {
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis').hide();
$("#editpdlplus_axes option:selected").html(axe[0].axelabel);
}
$("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
}).fail(notification.exception);
});
$("#axisFormCancel").on("click", function () {
if ('{{action}}' === 'add'){
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_div_addaxis').hide();
} else {
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html("");
$('#assignfeedback_editpdfplus_widget_admin_div_editaxis').hide();
}
$("#axistool").show();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
$("#editpdlplus_axes").prop('disabled',false);
});
});
{{/ 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