composer require ldc/web-status-checker-laravel remove Old static status checker Fix ImportMedia WIP commands OK many fixes Fix and try to optimize folder component Fix front icons + actions based on icons Favico front fix alert Fix Media upload on depot fix folder component buttons Full front fix with perf due tu vuejs Download medias Navigate within medias superfix Move media + loader isLocked boolean and remove media fix Folder scroll fix arcadia link color red Fix panier show external Tons of fixes back as front REwrited all
290 lines
9.1 KiB
JavaScript
290 lines
9.1 KiB
JavaScript
|
|
$(document).ready(function() {
|
|
|
|
// ---- Gestion des utilisateurs : filtre role
|
|
$(".filter_role_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_user_input").val('');
|
|
var roleId = $(".filter_role").val();
|
|
tableSearch('.datatable tr.data_row', 'attr-role', roleId)
|
|
});
|
|
|
|
// ---- Gestion des dossiers : filtre sujet
|
|
$(".filter_sujet_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_user_input").val('');
|
|
var sujetId = $(".filter_sujet").val();
|
|
tableSearch('.datatable tr.data_row', 'attr-sujet', sujetId)
|
|
});
|
|
|
|
// ---- Gestion des utilisateurs : recherche d'utilisateur
|
|
$(".filter_user_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_role").val(0);
|
|
var search = $(".filter_user_input").val();
|
|
tableGlobalSearch('.datatable tr.data_row', search, [1,2,3]);
|
|
});
|
|
|
|
// ---- Gestion des dossiers : recherche un dossier
|
|
$(".filter_dossier_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_sujet").val(0);
|
|
var search = $(".filter_dossier_input").val();
|
|
tableGlobalSearch('.datatable tr.data_row', search, [1]);
|
|
});
|
|
|
|
// ---- Edition des utilisateurs : validation formulaire
|
|
$('#submitEdit').on('click', () => {
|
|
$('.dataform').trigger('submit')
|
|
})
|
|
|
|
// ---- Edition des utilisateurs : suppression d'utilisateur
|
|
$(".btn_delete_user").on('click', function(event) {
|
|
event.preventDefault();
|
|
let form = $('.deleteform'), created_by = $('select[name="created_by"]').val(),
|
|
created_by_text = $('select[name="created_by"] option:selected').text()
|
|
if (!created_by.length) {
|
|
$.fancyConfirm({
|
|
title: 'Impossible de lancer cet action.',
|
|
message: 'Vous devez choisir autre un utilisateur à qui assigner les fiches.',
|
|
okButton: 'Compris',
|
|
noButton: 'Retour'
|
|
})
|
|
return;
|
|
}
|
|
$.fancyConfirm({
|
|
title: 'Suppression d\'un utilisateur',
|
|
message: 'Les média seront assignés à ' + created_by_text + '. Êtes-vous sûr de vouloir supprimer cet utilisateur ?',
|
|
okButton: 'Supprimer',
|
|
noButton: 'Annuler',
|
|
callback: function (value) {
|
|
if (value) {
|
|
form.trigger('submit')
|
|
}
|
|
}
|
|
})
|
|
});
|
|
|
|
// ---- Edition des dossiers : suppression d'un dossier
|
|
$(".btn_delete_dossier").on('click', function(event) {
|
|
event.preventDefault();
|
|
var form = $(".deleteform");
|
|
$.fancyConfirm({
|
|
title : "Suppression d'un dossier",
|
|
message : "Êtes-vous sûr de vouloir supprimer ce dossier ?",
|
|
okButton : 'Supprimer',
|
|
noButton : 'Annuler',
|
|
callback : function (value) {
|
|
if (value) {
|
|
form.submit();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// ---- Ajout des utilisateurs : vérification du matricule
|
|
$(".check_matricule").on('blur', function(event) {
|
|
var matricule = $(this).val();
|
|
if(matricule == "") return false;
|
|
|
|
$(".loader").show();
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
|
|
$.ajax({
|
|
url: '/check-matricule',
|
|
method: 'POST',
|
|
dataType : 'json',
|
|
data: {
|
|
matricule: matricule,
|
|
},
|
|
success: function(result){
|
|
$(".loader").hide();
|
|
if(result.exist_bdd){
|
|
$.fancyMessage({
|
|
title : "Attention",
|
|
message : "Ce matricule existe déjà. Veuillez en indiquer un autre.",
|
|
type : "error",
|
|
});
|
|
}else if(result.exist_ldap){
|
|
$("#firstname").val(result.ldap_user.firstname);
|
|
$("#lastname").val(result.ldap_user.lastname);
|
|
$("#email").val(result.ldap_user.email);
|
|
$.fancyMessage({
|
|
title : "Information",
|
|
message : "Ce matricule existe chez LDC. Le formulaire a été complété.",
|
|
type : "info",
|
|
});
|
|
}
|
|
},
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
$(".loader").hide();
|
|
}
|
|
});
|
|
});
|
|
|
|
// Rechercher ID Arcadia pour réactivation
|
|
$("#recovery-form").submit(function (e) {
|
|
e.preventDefault();
|
|
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
|
|
const id = $("input[name='arcadia_id']").val();
|
|
|
|
$.ajax({
|
|
url: '/ajax/check-arcadia-id',
|
|
method: 'POST',
|
|
dataType : 'json',
|
|
data: {
|
|
id: id,
|
|
},
|
|
success: function(result){
|
|
if (result === false){
|
|
$.fancyMessage({
|
|
title : "Attention",
|
|
message : "Aucun média supprimé avec cet ID Arcadia.",
|
|
type : "error",
|
|
});
|
|
}else{
|
|
$.fancyConfirm({
|
|
title : "Attention",
|
|
message : "Êtes-vous sûr de vouloir lancer le traitement ?",
|
|
okButton : 'Oui',
|
|
noButton : 'Non',
|
|
callback : function (value) {
|
|
if (value) {
|
|
$.ajax({
|
|
url: '/ajax/recover-media',
|
|
method: 'POST',
|
|
dataType : 'json',
|
|
data: {
|
|
arcadia_id: id,
|
|
},
|
|
success: function(result){
|
|
$.fancyMessage({
|
|
title : "Information",
|
|
message : "La demande de récupération a été faite.",
|
|
type : "info",
|
|
});
|
|
},
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
$.fancyMessage({
|
|
title: "Erreur",
|
|
message: "Une erreur est survenue",
|
|
type: "error",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
|
|
}
|
|
});
|
|
$("input[name='arcadia_id']").val('');
|
|
});
|
|
|
|
initSelector(".selector_marques");
|
|
initSelector(".selector_sujets");
|
|
});
|
|
|
|
|
|
// ---- Module de gestion de liste de données
|
|
window.initSelector = function($selector){
|
|
var datavalue = [];
|
|
|
|
// Init du module
|
|
$($selector+" .selector_values li").each(function() {
|
|
datavalue.push($(this).attr("data-value"));
|
|
});
|
|
$($selector+" .selector_choices li").each(function() {
|
|
var id = $(this).attr("data-value");
|
|
if(datavalue.indexOf(id)!= -1){
|
|
$(this).addClass('selected');
|
|
}
|
|
});
|
|
$($selector+" .selector_dataValues").val(datavalue.join());
|
|
|
|
// Recherche d'un élément
|
|
$($selector+" .selector_filter").off().on('keyup', function(event) {
|
|
var options = $(this).parent($selector).find(".selector_choices li");
|
|
var search = $(this).val();
|
|
$(options).each(function() {
|
|
|
|
if($(this).html().toUpperCase().indexOf(search.toUpperCase()) != -1 || search == ""){
|
|
$(this).css("display", "block");
|
|
}else{
|
|
$(this).css("display", "none");
|
|
}
|
|
});
|
|
});
|
|
|
|
// Ajout d'un élément
|
|
$($selector+" .selector_choices" ).off().on( "click", "li", function() {
|
|
if(!$(this).hasClass('selected')){
|
|
var id = $(this).attr("data-value");
|
|
var text = $(this).html();
|
|
$(this).addClass('selected');
|
|
$(this).parent().parent().find('.selector_values').append('<li data-value="'+id+'">'+text+' </li>');
|
|
datavalue.push(id);
|
|
$($selector+" .selector_dataValues").val(datavalue.join());
|
|
}
|
|
});
|
|
// Suppression d'un élément
|
|
$($selector+" .selector_values" ).off().on( "click", "li", function() {
|
|
var id = $(this).attr("data-value");
|
|
var text = $(this).html();
|
|
$(this).parent().parent().find('.selector_choices li[data-value="'+id+'"]').removeClass('selected');
|
|
$(this).remove();
|
|
var index = datavalue.indexOf(id);
|
|
if (index > -1) {
|
|
datavalue.splice(index, 1);
|
|
}
|
|
$($selector+" .selector_dataValues").val(datavalue.join());
|
|
});
|
|
};
|
|
|
|
|
|
// --- Fct pour rechercher sur un attribut d'une ligne
|
|
function tableSearch(field, attr, search){
|
|
$(field).each(function (index, value) {
|
|
if($(this).attr(attr) == search || search == 0){
|
|
$(this).show();
|
|
}else{
|
|
$(this).hide();
|
|
}
|
|
});
|
|
}
|
|
|
|
// --- Fct pour rechercher dans des colonnes d'une table
|
|
function tableGlobalSearch(field, search, cols){
|
|
var search = search.toUpperCase();
|
|
|
|
$(field).each(function (index, value) {
|
|
var $row = $(this);
|
|
var find = false;
|
|
$.each(cols, function (index, value) {
|
|
var dataCol = $row.find("td:nth-of-type("+value+")").text().toUpperCase();
|
|
|
|
if (dataCol.indexOf(search) != -1) {
|
|
find = true;
|
|
return false;
|
|
}
|
|
});
|
|
|
|
if(find){
|
|
$row.show();
|
|
}else{
|
|
$row.hide();
|
|
}
|
|
});
|
|
}
|