mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
PHRAS-978 - fix task management form
This commit is contained in:
@@ -264,7 +264,6 @@ class TaskManagerController extends Controller
|
|||||||
|
|
||||||
return $this->app->json(['success' => true]);
|
return $this->app->json(['success' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->app->json([
|
return $this->app->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => implode("\n", iterator_to_array($form->getErrors())),
|
'message' => implode("\n", iterator_to_array($form->getErrors())),
|
||||||
|
@@ -68,7 +68,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="menu">
|
<td class="menu">
|
||||||
<div class="btn-group dropdown">
|
<div class="btn-group dropdown">
|
||||||
<a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
|
<a class="btn btn-mini dropdown-toggle disabled" data-toggle="dropdown" href="#">
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
@@ -1,96 +1,121 @@
|
|||||||
<div id="taskBody">
|
<div id="taskBody">
|
||||||
{% block css %}{% endblock %}
|
{% block css %}{% endblock %}
|
||||||
<div>
|
<form
|
||||||
|
name="task-edit"
|
||||||
|
method="POST"
|
||||||
|
action="{{ path('admin_tasks_task_save', {'task' : task.getId()}) }}"
|
||||||
|
class="form-horizontal no-ajax">
|
||||||
|
{% if form.vars.errors|length > 0 %}
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
{% endif %}
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{ 'Task Edition' | trans }}</legend>
|
||||||
|
<div class="control-group">
|
||||||
|
|
||||||
|
<label class="control-label">{{ form_label(form.name) }} {{ form_errors(form.name) }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
{{ form_widget(form.name) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
|
||||||
<div>
|
<label class="control-label">{{ form_label(form.period) }} {{ form_errors(form.period) }}</label>
|
||||||
{{ 'admin::tasks: Nombre de crashes :' | trans }} <span id="crash-counter">{{ task.getCrashed() }}</span>
|
<div class="controls">
|
||||||
<button class="btn btn-success" id="taskResetCrashCounterButton">
|
{{ form_widget(form.period) }}
|
||||||
{{ 'admin::tasks: reinitialiser el compteur de crashes' | trans }}
|
</div>
|
||||||
</button>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
|
||||||
|
<label class="control-label">{{ form_label(form.status) }} {{ form_errors(form.status) }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
{{ form_widget(form.status) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ form_rest(form) }}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<div class="form-horizontal">
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label">{{ 'admin::tasks: Nombre de crashes :' | trans }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input class="formElem input-mini" type="text" name="crash-counter" value="{{ task.getCrashed() }}" readonly>
|
||||||
|
<button class="btn btn-success btn-mini" id="taskResetCrashCounterButton">
|
||||||
|
{{ 'admin::tasks: reinitialiser el compteur de crashes' | trans }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="taskTabs">
|
<div id="taskTabs">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#taskXmlTab">{{ 'boutton::vue xml' | trans }}</a></li>
|
<li><a href="#taskXmlTab">{{ 'boutton::vue xml' | trans }}</a></li>
|
||||||
<li><a href="#taskGuiTab">{{ 'boutton::vue graphique' | trans }}</a></li>
|
<li><a href="#taskGuiTab">{{ 'boutton::vue graphique' | trans }}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id="taskGuiTab" >
|
<div id="taskGuiTab">
|
||||||
<form id="graphicForm" name="graphicForm" class="form-horizontal" onsubmit="return(false);" method="post">
|
<form id="graphicForm" name="graphicForm" class="form-horizontal" onsubmit="return(false);" method="post">
|
||||||
{% block form %}{% endblock %}
|
{% block form %}{% endblock %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="taskXmlTab">
|
<div id="taskXmlTab">
|
||||||
{% block xml_settings %}
|
{% block xml_settings %}
|
||||||
<form onsubmit="return(false);" name="fxml" method="post">
|
<form onsubmit="return(false);" name="fxml" method="post">
|
||||||
<textarea nowrap id="txtareaxml" style="white-space:pre; width:100%; height:250px" name="txtareaxml" >{{task.getSettings()}}</textarea>
|
<textarea nowrap id="txtareaxml" style="white-space:pre; width:100%; height:250px" name="txtareaxml">{{ task.getSettings() }}</textarea>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form
|
|
||||||
name="task-edit"
|
|
||||||
method="POST"
|
|
||||||
action="{{ path('admin_tasks_task_save', {'task' : task.getId()}) }}"
|
|
||||||
class="form-inline no-ajax"
|
|
||||||
>
|
|
||||||
{% if form.vars.errors|length > 0 %}
|
|
||||||
{{ form_errors(form) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{{ form_rest(form) }}
|
<div class="form-actions">
|
||||||
|
<button type="submit" class="btn btn-primary btn-trigger " id="taskSaveButton" form="task-edit">
|
||||||
<div class="form-actions">
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary btn-trigger " id="taskSaveButton">
|
|
||||||
{{ "Save" | trans }}
|
{{ "Save" | trans }}
|
||||||
</button>
|
</button>
|
||||||
<a href="{{ path('admin_tasks_list') }}">{{ 'Cancel' | trans }}</a>
|
<a href="{{ path('admin_tasks_list') }}">{{ 'Cancel' | trans }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function taskFillGraphic(xml) { };
|
function taskFillGraphic(xml) {};
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function () {
|
||||||
$("#taskTabs").tabs({
|
$("#taskTabs").tabs({
|
||||||
create: function(event, ui) {
|
create: function (event, ui) {
|
||||||
$("#taskTabs").tabs({ active: 1 });
|
$("#taskTabs").tabs({active: 1});
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
beforeActivate: function(event, ui) {
|
beforeActivate: function (event, ui) {
|
||||||
switch($(ui.newPanel).attr("id"))
|
switch ($(ui.newPanel).attr("id")) {
|
||||||
{
|
|
||||||
case "taskGuiTab":
|
case "taskGuiTab":
|
||||||
|
|
||||||
var validated = false;
|
var validated = false;
|
||||||
// click on gui tab : fill the gui from xml, then switch to the gui view
|
// click on gui tab : fill the gui from xml, then switch to the gui view
|
||||||
$.ajax({
|
$.ajax({
|
||||||
"url" : "{{ path('admin_tasks_validate_xml') }}",
|
"url": "{{ path('admin_tasks_validate_xml') }}",
|
||||||
"data" : $("#txtareaxml").val(),
|
"data": $("#txtareaxml").val(),
|
||||||
"processData" : false,
|
"processData": false,
|
||||||
"dataType" : "text",
|
"dataType": "text",
|
||||||
"type" : "POST",
|
"type": "POST",
|
||||||
"async" : false,
|
"async": false,
|
||||||
success : function(data) {
|
success: function (data) {
|
||||||
var x = $("#txtareaxml").val();
|
var x = $("#txtareaxml").val();
|
||||||
try {
|
try {
|
||||||
taskFillGraphic(x);
|
taskFillGraphic(x);
|
||||||
validated = true;
|
validated = true;
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
// todo add notification
|
// todo add notification
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error:function(jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
// todo add notification
|
// todo add notification
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -104,17 +129,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#taskResetCrashCounterButton").click(function()
|
$("#taskResetCrashCounterButton").click(function () {
|
||||||
{
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
"url" : "{{ path('admin_tasks_task_reset', {'task' : task.getId()}) }}",
|
"url": "{{ path('admin_tasks_task_reset', {'task' : task.getId()}) }}",
|
||||||
"dataType" : "json",
|
"dataType": "json",
|
||||||
"type" : "POST",
|
"type": "POST",
|
||||||
success:function(data) {
|
success: function (data) {
|
||||||
if(!data.success) {
|
if (!data.success) {
|
||||||
//todo add notification and loader
|
//todo add notification and loader
|
||||||
} else {
|
} else {
|
||||||
$("#crash-counter").html("0");
|
$("input[name='crash-counter']").val("0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -122,53 +146,47 @@
|
|||||||
|
|
||||||
function xmlFromForm(callback) {
|
function xmlFromForm(callback) {
|
||||||
var formData = $("#graphicForm").serializeArray();
|
var formData = $("#graphicForm").serializeArray();
|
||||||
formData.push({"name":"xml", "value":$("#txtareaxml").val()});
|
formData.push({"name": "xml", "value": $("#txtareaxml").val()});
|
||||||
$.ajax({ url: "{{ path('admin_tasks_xml_from_form', {'task' : task.getId()}) }}"
|
$.ajax({
|
||||||
|
url: "{{ path('admin_tasks_xml_from_form', {'task' : task.getId()}) }}"
|
||||||
, data: formData
|
, data: formData
|
||||||
, dataType:'text'
|
, dataType: 'text'
|
||||||
, type:"POST"
|
, type: "POST"
|
||||||
, success:function(data) {
|
, success: function (data) {
|
||||||
$("#txtareaxml").val(data);
|
$("#txtareaxml").val(data);
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(data);
|
callback(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, error:function(jqXHR, textStatus, errorThrown) {
|
, error: function (jqXHR, textStatus, errorThrown) {
|
||||||
console.log(jqXHR.responseText);
|
console.log(jqXHR.responseText);
|
||||||
// todo add a notification message
|
// todo add a notification message
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$("form[name='task-edit']").on('submit', function()
|
$('#taskSaveButton').on('click', function () {
|
||||||
{
|
$("form[name='task-edit']").submit();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("form[name='task-edit']").on('submit', function () {
|
||||||
xmlFromForm(function (data) {
|
xmlFromForm(function (data) {
|
||||||
$("form[name='task-edit'] input[name='settings']").val(data);
|
$("form[name='task-edit'] input[name='settings']").val(data);
|
||||||
formData = $("form[name='task-edit']").serializeArray();
|
formData = $("form[name='task-edit']").serializeArray();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ path('admin_tasks_task_save', { 'task' : task.getID() }) }}"
|
url: "{{ path('admin_tasks_task_save', { 'task' : task.getID() }) }}"
|
||||||
, data: formData
|
, data: formData
|
||||||
, dataType:'json'
|
, dataType: 'json'
|
||||||
, type:"POST"
|
, type: "POST"
|
||||||
, async:false
|
, async: false
|
||||||
, success:function(data) {
|
, success: function (data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
console.log('should go back to list');
|
console.log('should go back to list');
|
||||||
//loadRightAjax("{{ path('admin_tasks_list') }}");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* var $this = $(this);
|
|
||||||
$('#right-ajax').empty().addClass('loading').parent().show();
|
$('#right-ajax').empty().addClass('loading').parent().show();
|
||||||
$('#right').hide();
|
$('#right').hide();
|
||||||
$.get($this.attr('href'), function (data) {
|
$.get("{{ path('admin_tasks_list') }}", function (data) {
|
||||||
$('#right-ajax').removeClass('loading').html(data);
|
$('#right-ajax').removeClass('loading').html(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (window.console) {
|
if (window.console) {
|
||||||
console.log(data.message);
|
console.log(data.message);
|
||||||
@@ -176,7 +194,7 @@
|
|||||||
alert("{{ 'An error occured' | trans | e('js') }}" + data.message);
|
alert("{{ 'An error occured' | trans | e('js') }}" + data.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, error:function(jqXHR, textStatus, errorThrown) {
|
, error: function (jqXHR, textStatus, errorThrown) {
|
||||||
alert("Erreur XML:\n\n" + jqXHR.responseText);
|
alert("Erreur XML:\n\n" + jqXHR.responseText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user