Newer
Older
// LEGACY !!!!!!!
// Change destination entity_id => load new listmodel with script load_listinstance
function change_entity(
entity_id,
path_manage_script,
diff_list_id,
origin_keyword,
display_value_tr,

Alex ORLUC
committed
load_listmodel,
if(category === undefined){
category = '';
}

SNA
committed
var div_id = diff_list_id || 'diff_list_div';
var tr_display_val = display_value_tr || 'table-row';
var origin_arg = origin_keyword || '';
var load_listmodel = load_listmodel || 'true';

SNA
committed
{
var isMandatory = $j('#destination_mandatory').css('display');

SNA
committed
}
else
{
var isMandatory = "none";
}
if(entity_id != null)
{
$j.ajax({
url: path_manage_script,
type: 'POST',
data: {
objectType : 'entity_id',
objectId : entity_id,
collId : 'letterbox_coll',
load_from_model : load_listmodel,
origin : origin_arg,
mandatory : isMandatory,
category : category
},
success: function(answer){
eval("response = "+answer);

SNA
committed
if(response.status == 0 )
{
var diff_list_tr = $j('#diff_list_tr');
var diff_list_div = $j("#"+div_id);

SNA
committed
if(diff_list_div != null)
{
diff_list_div.html(response.div_content);

SNA
committed
}
if(diff_list_tr)
{
diff_list_tr.css('display',tr_display_val);

SNA
committed
}
else
{

SNA
committed
}
}
else
{
var diff_list_tr = $j('#diff_list_tr');
var diff_list_div = $j("#"+div_id);

SNA
committed
if(diff_list_div != null)
{

SNA
committed
}
if(diff_list_tr)
{
diff_list_tr.css('display',tr_display_val);

SNA
committed
}
else
{

SNA
committed
}
try{
$j('#frm_error').html(response.error_txt);

SNA
committed
}
catch(e){}
}
}

SNA
committed
}
// Load list of listmodels to fill select list (index, validate)
// >>> type of list (entity_id, type_id, custom list type)
// >>> type of element to fill (select or list)
// >>> id of element to fill
function select_listmodels(
objectType,
returnElementType,
returnElementId
console.log('appel select_listmodels');
new Ajax.Request(
'index.php?display=true&module=entities&page=select_listmodels',
parameters: {
objectType : objectType,
returnElementType : returnElementType
{
var returnElement = $(returnElementId);
if(returnElement != null && returnElement.nodeName.toUpperCase() == returnElementType.toUpperCase()) {
returnElement.innerHTML += answer.responseText;
}
}
);
}
// Load listmodel to session[origin]
// >>> type of list (entity_id, type_id, custom list type)
// >>> id of list (entity_id, type_id, custom id)
// >>> id of div to fill
// >>> origin keyword
function load_listmodel(
selectedOption,
diff_list_id,

Alex ORLUC
committed
origin_keyword,
if(category === undefined){
category = '';
}
var div_id = diff_list_id || 'diff_list_div';
var origin = origin_keyword || '';
var objectType = selectedOption.getAttribute('data-object_type');
var objectId = selectedOption.value;
var diff_list_div = $j("#"+div_id);
$j.ajax({
url: 'index.php?display=true&module=entities&page=load_listmodel',
type: 'POST',
data: {
objectType : objectType,
objectId : objectId,
origin : origin,
category : category
},
success: function(answer){
eval("response = "+answer);
diff_list_div.html(response.div_content);
$j('#frm_error').html(response.error_txt);
origin,
display_value_tr,
difflist_div,

Alex ORLUC
committed
difflist_tr,
) {
console.log('test change_diff_list');
if(category === undefined){
category = '';
}
if(specific_role === undefined){
specific_role = '';
}

SNA
committed
var list_div = difflist_div || 'diff_list_div';
var list_div_from_action = 'diff_list_div_from_action';

SNA
committed
var list_tr = difflist_tr || 'diff_list_tr';
var tr_display_val = display_value_tr || 'table-row';
'index.php?display=true&module=entities&page=load_listinstance',

SNA
committed
{
method:'post',
parameters: {

Alex ORLUC
committed
origin : origin,
category : category,
specific_role : specific_role

SNA
committed
eval("response = "+answer.responseText);
//alert(answer.responseText);
if(response.status == 0 )
{
//alert(window.opener.document);
var diff_list_tr = window.opener.$(list_tr);
var diff_list_div = window.opener.$(list_div);
var diff_list_div_from_action = window.opener.$(list_div_from_action);

SNA
committed
if(diff_list_div != null)
{
diff_list_div.innerHTML = response.div_content;
}
if(diff_list_div_from_action != null)
{
diff_list_div_from_action.innerHTML = response.div_content_action;
}

SNA
committed
if(diff_list_tr != null)
{
diff_list_tr.style.display = tr_display_val;
}
if(window.opener.document.getElementById('save_list_diff')){
window.opener.document.getElementById('save_list_diff').click();
}
if(window.opener.parent.document.getElementById('iframe_tab')){
window.opener.parent.document.getElementById('iframe_tab').src = window.opener.parent.document.getElementById('iframe_tab').src;

SNA
committed
window.close();
}
else
{
try{
$('frm_error').innerHTML = response.error_txt;
}
catch(e){}
}
}
);
}
function isIdToken(value)
{
var token = value.match(/[\w_]+/g);
if(!token)
return false;
if(token[0] != value)
return false;
else
function validate_difflist_type() {
console.log('test validate_difflist_type');
var main_error = $('main_error');
var difflist_type_id = $('difflist_type_id').value;
var difflist_type_label = $('difflist_type_label').value;
var allow_entities = 'N';
if($('allow_entities').checked)
allow_entities = 'Y';
var difflist_type_roles = "";
var selected_roles = $('selected_roles');
for (var i=0;i<selected_roles.length;i++) {
difflist_type_roles = difflist_type_roles + selected_roles[i].value + " ";
}
var idValid = isIdToken(difflist_type_id);
if(idValid == false) {
main_error.innerHTML = 'Identifiant invalide (A-Z, a-z, 0-9 et _)';
return;
}
main_error.innerHTML = '';
'index.php?module=entities&page=admin_difflist_type_validate&display=true',
{
parameters:
difflist_type_id : difflist_type_id,
difflist_type_label : difflist_type_label,
difflist_type_roles : difflist_type_roles,
allow_entities : allow_entities
},
onSuccess: function(transport) {
var responseText = transport.responseText.replace(new RegExp("(\r|\n)", "g"), "");
if(responseText)
$('difflist_type_messages').innerHTML += responseText;
else
goTo('index.php?module=entities&page=admin_difflist_types');
function saveListDiff(mode, table, collId, resId, userId, concatList, onlyCC) {
new Ajax.Request(
'index.php?display=true&module=entities&page=save_list_diff',
{
method:'post',
parameters: {
mode : mode,
table : table,
collId : collId,
resId : resId,
userId : userId,
concatList : concatList,
onlyCC : onlyCC,
},
onSuccess: function(answer){
eval("response = "+answer.responseText);
if (response.status == 0) {
var div_diff_list_message = $('div_diff_list_message');
if (div_diff_list_message != null) {
div_diff_list_message.innerHTML = response.div_content;
Element.hide.delay(2, 'div_diff_list_message');
}
if(parent.$('diffList_iframe')){
parent.$('diffList_iframe').src = parent.$('diffList_iframe').src;
}