PHRAS-3006

This commit is contained in:
Harrys Ravalomanana
2020-04-02 19:37:44 +04:00
parent ca02542b96
commit 11e729ca1e
3 changed files with 6 additions and 158 deletions

View File

@@ -65,7 +65,7 @@
"normalize-css": "^2.1.0", "normalize-css": "^2.1.0",
"npm": "^6.0.0", "npm": "^6.0.0",
"npm-modernizr": "^2.8.3", "npm-modernizr": "^2.8.3",
"phraseanet-production-client": "0.34.161-d", "phraseanet-production-client": "0.34.162-d",
"requirejs": "^2.3.5", "requirejs": "^2.3.5",
"tinymce": "^4.0.28", "tinymce": "^4.0.28",
"underscore": "^1.8.3", "underscore": "^1.8.3",

View File

@@ -12,155 +12,3 @@
<div id="delete_records_with_children"> <div id="delete_records_with_children">
{{ include('prod/actions/delete_records_confirm_form.html.twig', with_children) }} {{ include('prod/actions/delete_records_confirm_form.html.twig', with_children) }}
</div> </div>
<script type="text/javascript">
var $dialog = p4.Dialog.get(1),
$dialogBox = $dialog.getDomElement(),
$closeButton = $("button.ui-dialog-titlebar-close", $dialogBox.parent()),
$cancelButton = $("button.cancel", $dialogBox),
// $titleBox = $(".ui-dialog-title", $dialogBox.parent()),
$delChildren = $("input[name='del_children']", $dialogBox);
/**
* set the dlg content according the "delete children" ckbox
* the counts (records will be deleted, records rejected...) will update
*/
var fSetDelChildren = function(delChildren) {
if(delChildren) {
$("#delete_records_parent_only").hide();
$("#delete_records_with_children").show();
}
else {
$("#delete_records_with_children").hide();
$("#delete_records_parent_only").show();
}
};
/**
* the checkbox "delete stories children too" changes
*/
$delChildren.bind("change", function () {
fSetDelChildren($(this).is(':checked'));
});
/**
* click cancel before ok : simply close the dlg
*/
$cancelButton.bind("click", function () {
// while no task is running, simply close the dlg
$dialog.Close();
});
/**
* click ok : run delete tasks
*/
$("button.submiter", $dialogBox).bind("click", function () {
var CHUNKSIZE = 3,
MAXTASKS = 5;
var $this = $(this); // the submit button
$this.prop('disabled', true)
.hide();
var $form = $(this).closest("form"),
$counter = $form.find(".to_delete_count"),
$trash_counter = $form.find(".to_trash_count"),
$loader = $form.find(".form-action-loader");
var lst = $("input[name='lst']", $form).val().split(';');
/**
* same parameters for every delete call, except the list of (CHUNKSIZE) records
* nb: do NOT ask to delete children since they're included in lst
*/
var ajaxParms = {
type: $form.attr("method"),
url: $form.attr("action"),
data: {
'lst': "" // set in f
},
dataType: "json"
};
var runningTasks = 0, // number of running tasks
canceling = false;
/**
* cancel or close dlg will ask tasks to stop
*/
var fCancel = function () {
$closeButton.hide();
$cancelButton.hide();
$loader.show();
canceling = true;
};
/**
* task fct : will loop itself while there is job to do
*
* @param iTask (int) The task number 0...MAXTASKS-1, usefull only to debug
*/
var fTask = function (iTask) {
if (canceling) {
return;
}
// pop & truncate
ajaxParms.data.lst = lst.splice(0, CHUNKSIZE).join(';');
$.ajax(ajaxParms)
.done(function (data) { // prod feedback only if result ok
$.each(data, function (i, n) {
var $imgt = $('#IMGT_' + n),
$chim = $('.CHIM_' + n),
$stories = $('.STORY_' + n);
$('.doc_infos', $imgt).remove();
try {
$imgt.draggable("destroy");
}
catch (e) {
// no-op
}
$imgt.unbind("click")
.removeAttr("ondblclick")
.removeClass("selected")
.removeClass("IMGT")
.find("img")
.unbind();
$imgt.find(".thumb img")
.attr("src", "/assets/common/images/icons/deleted.png")
.css({
width: '100%',
height: 'auto',
margin: '0 10px',
top: '0'
});
$chim.parent().slideUp().remove();
$imgt.find(".status,.title,.bottom").empty();
p4.Results.Selection.remove(n);
if ($stories.length > 0) {
p4.WorkZone.refresh();
}
else {
p4.WorkZone.Selection.remove(n);
}
});
})
.then(function () { // go on even in case of error
// countdown
$counter.html(lst.length);
$trash_counter.html(lst.length);
if (lst.length === 0 || canceling) {
// end of a task
if (--runningTasks === 0) {
$dialog.Close();
viewNbSelect();
}
}
else {
// don't recurse, give a delay to running fct to end
window.setTimeout(fTask, 10, iTask);
}
});
};
// cancel or close the dlg is the same : wait
$dialog.setOption('closeOnEscape', false);
$closeButton.unbind("click").bind("click", fCancel);
$cancelButton.unbind("click").bind("click", fCancel);
// run a bunch of tasks in //
for (runningTasks = 0; runningTasks < MAXTASKS && lst.length > 0; runningTasks++) {
fTask(runningTasks); // pass the task his index to get nice console logs
}
});
// $titleBox.prepend('<i class="icon-warning-sign" style="margin-right: 10px"></i>');
// by default, do not delete children of stories : uncheck
fSetDelChildren(false);
</script>

View File

@@ -7577,10 +7577,10 @@ phraseanet-common@^0.4.5-d:
js-cookie "^2.1.0" js-cookie "^2.1.0"
pym.js "^1.3.1" pym.js "^1.3.1"
phraseanet-production-client@0.34.161-d: phraseanet-production-client@0.34.162-d:
version "0.34.161-d" version "0.34.162-d"
resolved "https://registry.yarnpkg.com/phraseanet-production-client/-/phraseanet-production-client-0.34.161-d.tgz#f0b93e342af25d3064562c1420f24514bb5a94f9" resolved "https://registry.yarnpkg.com/phraseanet-production-client/-/phraseanet-production-client-0.34.162-d.tgz#4bfbb6998bae864f5be2eefba87b07ef06f7e4e6"
integrity sha512-3nfnMjLctLp5LysO83uuWSrHQ71b+dKd4Tt8mcHV1zQcYKkXQkcXYI5/UBCna/im83zNtpz2/tSPKw5h3j3TDg== integrity sha512-FVXzj0Qi6DQSJnv3LrCiIaEUZ0A1DoOn3kUGPBpgws+EzXS13tFC6W0eLz/gDgw/L9Y82S60gI9s778fadwoew==
dependencies: dependencies:
"@mapbox/mapbox-gl-language" "^0.9.2" "@mapbox/mapbox-gl-language" "^0.9.2"
"@turf/turf" "^5.1.6" "@turf/turf" "^5.1.6"