Gitlab CSE Unil

Commit 05e8e0e9 authored by M. Chardon's avatar M. Chardon
Browse files

tool enabled/disabled

parent 202abb9e
define(["jquery","core/notification","core/templates","core/fragment","core/ajax"],function(a,b,c,d,e){var f=null,g=function(a){this.init(),f=a};g.prototype.selectTool=null,g.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();a("#editpdlplus_toolbar_"+b).show();var c=a("#editpdlplus_axes option:selected").data("delete");c&&parseInt(c)>0?a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").addClass("disabled"):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",i),this.selectTool=a(".editpdlplus_tool").first(),this.initTool(),a("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click",this.openDivAddAxis),a("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click",this.openDivEditAxis),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click",this.openDivDelAxis),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click",this.openDivAddTool)},g.prototype.test=function(){alert("test"),i()},g.prototype.initTool=function(){a(this.selectTool).removeClass("btn-default"),a(this.selectTool).addClass("btn-primary")},g.prototype.openDivAddAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body").html("");var e={};d.loadFragment("assignfeedback_editpdfplus","axisadd",f,e).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},g.prototype.openDivEditAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisedit",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},g.prototype.openDivDelAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisdel",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)};var h=function(b,d,e){var f=a.Deferred();return b.fadeOut("fast",function(){c.replaceNodeContents(b,d,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()},i=function(){var c=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).removeClass("btn-default");var b=a(this).data("enable");1===b&&a(this).val()!==c&&a(this).addClass("btn-default")}),a(this).addClass("btn-primary"),a("#editpdlplus_tool_item").html("");var g={toolid:c};d.loadFragment("assignfeedback_editpdfplus","tooledit",f,g).done(function(c,d){h(a("#editpdlplus_tool_item"),c,d).done(function(){a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Modifications enregistrées"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",i)}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.exception)})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return g.prototype.openDivAddTool=function(){a("#editpdlplus_tool_item").html(""),a(".btn-primary").addClass("btn-default"),a(".editpdlplus_tool").removeClass("btn-primary");var c=a("#editpdlplus_axes option:selected").val(),g={axisid:c};d.loadFragment("assignfeedback_editpdfplus","tooladd",f,g).done(function(c,d){h(a("#editpdlplus_tool_item"),c,d).done(function(){a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Ajout enregistré"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",i),a("#editpdlplus_tool_item").html()}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.exception)})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)},g});
\ No newline at end of file
define(["jquery","core/notification","core/templates","core/fragment","core/ajax"],function(a,b,c,d,e){var f=null,g=function(a){this.init(),f=a};g.prototype.selectTool=null,g.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();a("#editpdlplus_toolbar_"+b).show();var c=a("#editpdlplus_axes option:selected").data("delete");c&&parseInt(c)>0?a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").addClass("disabled"):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",i),this.selectTool=a(".editpdlplus_tool").first(),this.initTool(),a("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click",this.openDivAddAxis),a("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click",this.openDivEditAxis),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click",this.openDivDelAxis),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click",this.openDivAddTool)},g.prototype.test=function(){alert("test"),i()},g.prototype.initTool=function(){a(this.selectTool).removeClass("btn-default"),a(this.selectTool).addClass("btn-primary")},g.prototype.openDivAddAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body").html("");var e={};d.loadFragment("assignfeedback_editpdfplus","axisadd",f,e).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},g.prototype.openDivEditAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisedit",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},g.prototype.openDivDelAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisdel",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)};var h=function(b,d,e){var f=a.Deferred();return b.fadeOut("fast",function(){c.replaceNodeContents(b,d,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()},i=function(){var c=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).removeClass("btn-default");var b=a(this).data("enable");1===b&&a(this).val()!==c&&a(this).addClass("btn-default")}),a(this).addClass("btn-primary"),a("#editpdlplus_tool_item").html("");var g={toolid:c};d.loadFragment("assignfeedback_editpdfplus","tooledit",f,g).done(function(c,d){h(a("#editpdlplus_tool_item"),c,d).done(function(){a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Modifications enregistrées"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",i)}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.exception)}),a("#toolEnabled").on("click",function(){var b=a("#toolenabled").val();1==b?(a("#toolEnabled > i").addClass("fa-eye-slash"),a("#toolEnabled > i").removeClass("fa-eye"),a("#toolenabled").val(0)):(a("#toolEnabled > i").addClass("fa-eye"),a("#toolEnabled > i").removeClass("fa-eye-slash"),a("#toolenabled").val(1)),a("#toolFormSubmit").click()})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return g.prototype.openDivAddTool=function(){a("#editpdlplus_tool_item").html(""),a(".btn-primary").addClass("btn-default"),a(".editpdlplus_tool").removeClass("btn-primary");var c=a("#editpdlplus_axes option:selected").val(),g={axisid:c};d.loadFragment("assignfeedback_editpdfplus","tooladd",f,g).done(function(c,d){h(a("#editpdlplus_tool_item"),c,d).done(function(){a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Ajout enregistré"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",i),a("#editpdlplus_tool_item").html("")}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.exception)})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)},g});
\ No newline at end of file
......@@ -218,6 +218,19 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
}
}).fail(notification.exception);
});
$("#toolEnabled").on("click", function () {
var enabled = $("#toolenabled").val();
if (enabled == 1) {
$("#toolEnabled > i").addClass("fa-eye-slash");
$("#toolEnabled > i").removeClass("fa-eye");
$("#toolenabled").val(0);
} else {
$("#toolEnabled > i").addClass("fa-eye");
$("#toolEnabled > i").removeClass("fa-eye-slash");
$("#toolenabled").val(1);
}
$("#toolFormSubmit").click();
});
}.bind(this)).fail(notification.exception);
//templates.appendNodeContents('#editpdlplus_tool_item', html, js).done(function () {
//alert("jdikdi");
......
......@@ -208,6 +208,37 @@ class admin_editor {
public static function edit_tool($toolJson) {
global $DB;
$tools = array();
$records = $DB->get_records('assignfeedback_editpp_tool', array('axis' => $data->axisid));
foreach ($records as $record) {
array_push($tools, new tool($record));
}
usort($tools, function($a, $b) {
$al = $a->order_tool;
$bl = $b->order_tool;
if ($al == $bl) {
return 0;
}
return ($al > $bl) ? +1 : -1;
});
$compteurPrecedent = null;
$decalage = 1;
foreach ($tools as $tool) {
if ($compteurPrecedent == null) {
$compteurPrecedent = $tool->order_tool;
} else {
$compteurCourant = $tool->order_tool;
if ($compteurCourant <= $compteurPrecedent) {
$tool->order_tool = $compteurPrecedent + $decalage;
//$decalage++;
}
$compteurPrecedent++;
}
}
foreach ($tools as $toolOr) {
$DB->update_record('assignfeedback_editpp_tool', $toolOr);
}
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $toolJson->toolid), '*', MUST_EXIST);
$tool = new tool($record);
$tool->type = $toolJson->typetool;
......@@ -216,8 +247,9 @@ class admin_editor {
$tool->cartridge_color = $toolJson->catridgecolor;
$tool->texts = $toolJson->texts;
$tool->label = $toolJson->button;
if ($toolJson->reply) {
$tool->reply = $toolJson->reply;
$tool->enabled = $toolJson->enabled;
if ($toolJson->reply == "on") {
$tool->reply = 1;
} else {
$tool->reply = 0;
}
......
......@@ -3,11 +3,11 @@
}}
<div class="alert" id="message_edit_tool">
</div>
<div class='row' style="margin-bottom: 10px;">
{{^tool.id}}<h4>Ajout d'un nouvel outil</h4>{{/tool.id}}
{{^tool.id}}<h4>Ajout d'un nouvel outil</h4>{{/tool.id}}
<div class='col-sm-1'>
<div id="editpdlplus_tool_label">{{#tool.id}}{{tool.label}}{{/tool.id}}</div>
</div>
......@@ -15,8 +15,8 @@
Action{{#tool.id}}s{{/tool.id}} :
<button type="button" class="btn btn-default" id="toolFormSubmit"><i class="fa fa-{{#tool.id}}pencil{{/tool.id}}{{^tool.id}}save{{/tool.id}}" aria-hidden="true"></i></button>
{{#tool.id}}
<button type="button" class="btn btn-default"><i class="fa fa-clone" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default"><i class="fa fa-eye-slash" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" id="toolClone"><i class="fa fa-clone" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" id="toolEnabled"><i class="fa fa-eye{{^tool.enabled}}-slash{{/tool.enabled}}" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default"><i class="fa fa-remove" aria-hidden="true"></i></button>
{{/tool.id}}
</div>
......@@ -119,12 +119,13 @@
</div>
</div>
</div>
<div style='display:none;'>
<input type="hidden" name="toolid" value="{{tool.id}}" />
<input type="hidden" name="axisid" value="{{tool.axis}}" />
<input type="hidden" name="courseid" value="{{courseid}}" />
<input type="hidden" name="sesskey" value="{{sesskey}}" />
<input type="hidden" name="enabled" id="toolenabled" value="{{tool.enabled}}" />
</div>
</form>
......@@ -136,7 +137,7 @@
{{# js }}
require(['jquery','core/ajax','core/notification'], function($,ajax,notification) {
{{#tool.id}}$("#typetool").val({{tool.type}});{{/tool.id}}
{{#tool.id}}$("#typetool").val({{tool.type}});{{/tool.id}}
});
{{/ 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