// Prevent multiple loading if (!T3_API_SITEMAP_XML_url) { // See into t3_string.js static file //var T3_API_"ENTITYNAME"_controller_name = Accounts var T3_API_SITEMAP_XML_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name; var T3_API_SITEMAP_XML_remote_control_message_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/RemoteControlMessage'; var T3_API_SITEMAP_XML_upload_xml_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/UploadXls'; var T3_API_SITEMAP_XML_html_entity_layout_url = T3_API_base_url + 'api/HtmlEntityLayouts/ByEntityName/sitemap_xml'; var T3_API_SITEMAP_XML_search_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/Search'; var T3_API_SITEMAP_XML_select_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name; var T3_API_SITEMAP_XML_new_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/New'; var T3_API_SITEMAP_XML_newsearchobject_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/NewSearchObject'; var T3_API_SITEMAP_XML_download_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/Download'; var T3_API_SITEMAP_XML_print_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/Print'; var T3_API_SITEMAP_XML_searchprint_url = T3_API_base_url + 'api/' + T3_API_SITEMAP_XML_controller_name + '/SearchPrint'; // See into t3_string.js static file //var T3_NG_"ENTITYNAME"_entity_label = 'Anagrafica'; //var T3_NG_"ENTITYNAME"_entities_label = 'Anagrafiche'; //var T3_NG_"ENTITYNAME"_of_entity_label = 'dell\'anagrafica'; //var T3_NG_"ENTITYNAME"_of_entities_label = 'deglle anagrafiche'; var T3_NG_SITEMAP_XML_page_title = 'SITEMAP_XML'; var T3_NG_SITEMAP_XML_new_error = T3_NG_ENTITY_new_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_save_error = T3_NG_ENTITY_save_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_remote_control_message_error = T3_NG_ENTITY_remote_control_message_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_delete_error = T3_NG_ENTITY_delete_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_search_error = T3_NG_ENTITY_search_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_select_error = T3_NG_ENTITY_select_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_newsearchobject_error = T3_NG_ENTITY_newsearchobject_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_get_html_entity_layout_error = T3_NG_ENTITY_get_html_entity_layout_error('SITEMAP_XML'); var T3_NG_SITEMAP_XML_form_error = T3_NG_ENTITY_form_error('SITEMAP_XML'); t3_ng_app_index.controller("t3_ng_ctr_sitemap_xml_select", function($scope, $http, t3_ng_svc_login, t3_ng_svc_exception) { // // md-select // $scope.loginData = t3_ng_svc_login; // $scope.searchObject_select = { // SelectTop: 100, // ByPattern: '', // OrderBy: { FieldName: "SequenceNo", Direction: 0 }, // Paging: null, // FastSearch: false // }; // if (T3_EN_FAST_SEARCH) // $scope.searchObject_select.FastSearch = true; // // Default value // $scope.fieldName = 'sitemap_xml'; // $scope.init_select = function(fieldName, filters, fastSearchFields) // { // // Define fieldname for the controller // if (fieldName) // { // $scope.fieldName = fieldName.toLowerCase(); // } // // Init static filters // if (filters) // { // //This function is sort of private constructor for controller // if (typeof filters === 'string' || filters instanceof String) // $scope.filters = JSON.parse(filters); // else // $scope.filters = filters; // // Copy filters into searchObject // for(var i in $scope.filters) $scope.searchObject_select[i]=$scope.filters[i]; // } // if (fastSearchFields) // { // //This function is sort of private constructor for controller // if (typeof fastSearchFields === 'string' || fastSearchFields instanceof String) // $scope.fastSearchFields = JSON.parse(fastSearchFields); // else // $scope.fastSearchFields = fastSearchFields; // // Copy filters into searchObject // if (!$scope.searchObject_select.FastSearchFields) // $scope.searchObject_select.FastSearchFields = []; // for(var i in $scope.fastSearchFields) // $scope.searchObject_select.FastSearchFields.push($scope.fastSearchFields[i]); // } // $scope.search_select(); // }; // $scope.searchResults_select = []; // $scope.search_select = function() { // // var cacheData = localStorage.t3_select_cache_SITEMAP_XML_data; // // var cacheTimestamp = localStorage.t3_select_cache_SITEMAP_XML_timestamp; // // if (!T3_DEBUG && cacheData && cacheTimestamp) // // { // // var cacheData = JSON.parse(cacheData); // // var cacheTimestamp = moment(JSON.parse(cacheTimestamp)); // // if (moment().diff(cacheTimestamp, 'seconds') < 30) // // { // // $scope.searchResults_select = decodeJsonReferences(cacheData); // // return; // // } // // } // $method = 'POST'; // $url = T3_API_SITEMAP_XML_search_url; // $http({ // method: $method, // url: $url, // headers: T3_API_authorized_request_headers($scope.loginData.token), // data: $scope.searchObject_select // }).then(function onSuccess(response) { // // Handle success // var data = response.data; // var status = response.status; // var statusText = response.statusText; // var headers = response.headers; // var config = response.config; // if (status == 200) // { // //localStorage.setItem('t3_select_cache_SITEMAP_XML_data', JSON.stringify(data)); // //localStorage.setItem('t3_select_cache_SITEMAP_XML_timestamp', JSON.stringify(moment())); // $scope.searchResults_select = decodeJsonReferences(data); // } // }).catch(function onError(response) { // // Handle error // var data = response.data; // var status = response.status; // var statusText = response.statusText; // var headers = response.headers; // var config = response.config; // if (status > 0) // t3_ng_svc_exception.exception(T3_NG_SITEMAP_XML_search_error, response, status); // }); // }; // // [end] md-select }); t3_ng_app_index.controller("t3_ng_ctr_sitemap_xml_autocomplete", function($scope, $http, t3_ng_svc_login, t3_ng_svc_exception, $q) { // // md-autocomplete // $scope.searchObject_autocomplete = { // SelectTop: 50, // ByPattern: '', // OrderBy: null, // Paging: null, // FastSearch: false // }; // if (T3_EN_FAST_SEARCH) // $scope.searchObject_autocomplete.FastSearch = true; // // Default value // $scope.fieldName = 'sitemap_xml'; // $scope.init_autocomplete = function(fieldName, filters, fastSearchFields) // { // // Define fieldname for the controller // if (fieldName) // { // $scope.fieldName = fieldName.toLowerCase(); // } // // Init static filters // if (filters) // { // //This function is sort of private constructor for controller // if (typeof filters === 'string' || filters instanceof String) // $scope.filters = JSON.parse(filters); // else // $scope.filters = filters; // // Copy filters into searchObject // for(var i in $scope.filters) $scope.searchObject_autocomplete[i]=$scope.filters[i]; // } // if (fastSearchFields) // { // //This function is sort of private constructor for controller // if (typeof fastSearchFields === 'string' || fastSearchFields instanceof String) // $scope.fastSearchFields = JSON.parse(fastSearchFields); // else // $scope.fastSearchFields = fastSearchFields; // // Copy filters into searchObject // if (!$scope.searchObject_autocomplete.FastSearchFields) // $scope.searchObject_autocomplete.FastSearchFields = []; // for(var i in $scope.fastSearchFields) // $scope.searchObject_autocomplete.FastSearchFields.push($scope.fastSearchFields[i]); // } // }; // $scope.prepareDynamicFilters = function(entity) // { // if (!$scope.filters) // return; // for(var i in $scope.filters) // { // if (typeof $scope.filters[i] == 'string' && $scope.filters[i].indexOf('@') == 0) // { // // Replace dinamic filter with entity specified field // $scope.searchObject_autocomplete[i]=entity[$scope.filters[i].substring(1, $scope.filters[i].length)] // } // else // { // $scope.searchObject_autocomplete[i]=$scope.filters[i]; // } // } // } // $scope.searchResults_autocomplete = []; // $scope.canceler = undefined; // $scope.search_autocomplete = function(entity, relatedEntityField, relatedEntityKey, text, searchCallback) { // if (!angular.isString(text)) // return; // if (text === undefined || text == "") // { // $scope.select_autocomplete(entity, relatedEntityField, relatedEntityKey, null, true); // return; // } // $method = 'POST'; // $url = T3_API_SITEMAP_XML_search_url; // $scope.prepareDynamicFilters(entity); // if ($scope.canceler) // $scope.canceler.resolve(); // $scope.canceler = $q.defer(); // $scope.searchResults_autocomplete = $http({ // method: $method, // url: $url, // headers: T3_API_authorized_request_headers($scope.loginData.token), // data: $scope.searchObject_autocomplete, // timeout: $scope.canceler.promise // }).then(function onSuccess(response) { // // Handle success // var data = response.data; // var status = response.status; // var statusText = response.statusText; // var headers = response.headers; // var config = response.config; // if (status == 200) // { // $scope.searchResults_autocomplete = decodeJsonReferences(data); // if (searchCallback && typeof searchCallback === "function") // searchCallback($scope.searchResults_autocomplete); // return $scope.searchResults_autocomplete; // } // return []; // }).catch(function onError(response) { // // Handle error // var data = response.data; // if (!data) // data = []; // var status = response.status; // var statusText = response.statusText; // var headers = response.headers; // var config = response.config; // if (status > 0) // t3_ng_svc_exception.exception(T3_NG_SITEMAP_XML_search_error, response, status); // }); // return $scope.searchResults_autocomplete; // }; // $scope.select_autocomplete = function(entity, relatedEntityField, relatedEntityKey, relatedEntity, clearRequest) { // if (!entity) // return; // if (!relatedEntity && !clearRequest) // return; // if (clearRequest || !relatedEntity) // { // $scope.searchObject_autocomplete.ByPattern = ''; // entity[relatedEntityField] = null; // entity[relatedEntityKey] = null; // // onUnLink event // if ($scope.$parent !== undefined && typeof $scope.onUnLink_sitemap_xml == 'function') { // $scope.$parent['onUnLink_' + $scope.fieldName](entity, relatedEntityField, relatedEntityKey, relatedEntity); // } // } // if (relatedEntity) // { // entity[relatedEntityField] = relatedEntity; // entity[relatedEntityKey] = relatedEntity.Id; // // onLink event // if ($scope !== undefined && typeof $scope['onLink_' + $scope.fieldName] == 'function') { // $scope['onLink_' + $scope.fieldName](entity, relatedEntityField, relatedEntityKey, relatedEntity); // } // // onLink event // else if ($scope.$parent !== undefined && typeof $scope.$parent['onLink_' + $scope.fieldName] == 'function') { // $scope.$parent['onLink_' + $scope.fieldName](entity, relatedEntityField, relatedEntityKey, relatedEntity); // } // else if ($scope.$parent.$parent !== undefined && typeof $scope.$parent.$parent['onLink_' + $scope.fieldName] == 'function') { // $scope.$parent.$parent['onLink_' + $scope.fieldName](entity, relatedEntityField, relatedEntityKey, relatedEntity); // } // } // }; // $scope.transformChip = function(chip) { // // If it is an object, it's already a known chip // if (angular.isObject(chip)) { // return chip; // } // } // $scope.applyHtmlEntityLayout = function(response) { // $scope.t3_html_entity_layout = response; // if (typeof(response.HtmlFieldLayouts) !== 'undefined') // { // $scope.t3_html_field_layout = response.HtmlFieldLayouts; // if (typeof(response.HtmlDetailFieldLayouts) !== 'undefined') // $scope.t3_html_detailfield_layout = response.HtmlDetailFieldLayouts; // else // t3_ng_svc_exception.exception(T3_NG_SITEMAP_XML_get_html_entity_layout_error, response, status); // } // else // { // t3_ng_svc_exception.exception(T3_NG_SITEMAP_XML_get_html_entity_layout_error, response, status); // return false; // } // return true; // } // // Get entity html field from APIs // $scope.getHtmlEntityLayout = function() { // var layout_session = sessionStorage.t3_html_SITEMAP_XML_layout; // var layout_local = localStorage.t3_html_SITEMAP_XML_layout; // // Apply session layout // if(typeof layout_session != "undefined" && layout_session !== '[object Object]') // { // layout_session = decodeJsonReferences(JSON.parse(layout_session)); // if ($scope.applyHtmlEntityLayout(layout_session)) // return; // } // // Apply temporary cache layout until server response with a fresh // if(typeof layout_local != "undefined" && layout_local !== '[object Object]') // { // layout_local = decodeJsonReferences(JSON.parse(layout_local)); // $scope.applyHtmlEntityLayout(layout_local); // } // $method = 'GET'; // $url = T3_API_SITEMAP_XML_html_entity_layout_url; // $http({ // method: $method, // url: $url, // headers: T3_API_authorized_request_headers($scope.loginData.token), // data: null // }).then(function onSuccess(response) { // // Handle success // var data = response.data; // var status = response.status; // var statusText = response.statusText; // var headers = response.headers; // var config = response.config; // if (status == 200) // { // sessionStorage.setItem( // 't3_html_sitemap_xml_layout', // JSON.stringify(data)); // $scope.applyHtmlEntityLayout(decodeJsonReferences(data)); // } // else // t3_ng_svc_exception.exception(T3_NG_SITEMAP_XML_get_html_entity_layout_error, response, status); // }).catch(function onError(response) { // // Handle error // var data = response.data; // var status = response.status; // var statusText = response.statusText; // var headers = response.headers; // var config = response.config; // t3_ng_svc_exception.exception(T3_NG_SITEMAP_XML_get_html_entity_layout_error, response, status); // }); // }; // $scope.t3_html_entity_layout = null; // $scope.t3_html_field_layout = null; // $scope.t3_html_detailfield_layout = null; // // Fire get field html layout // $scope.getHtmlEntityLayout(); // // [end] md-autocomplete }); }