From afc069afaa7fb45692b3fdc3c93207026f42d533 Mon Sep 17 00:00:00 2001 From: gamonoid Date: Sat, 17 Mar 2018 19:09:52 +0100 Subject: [PATCH] Translation updates and UI improvements --- api/Base.js | 2624 +++++++------- api/FormValidation.js | 416 ++- css/style.css | 21 +- lang/de-ext.po | 10 - lang/de.po | 20 +- lang/en-ext.po | 10 - lang/en.po | 19 +- lang/es.po | 3200 ++++++++--------- lang/fr.po | 3200 ++++++++--------- lang/hi.po | 1601 --------- lang/it.po | 3200 ++++++++--------- lang/ja.po | 3200 ++++++++--------- lang/pl.po | 3200 ++++++++--------- lang/si.po | 1601 --------- lang/zh.po | 3200 ++++++++--------- migrations/list.php | 1 + .../v20180305_210100_drop_si_hi_languages.php | 35 + robo/RoboFile.php | 93 + src/Classes/LanguageManager.php | 40 +- templates/fields/colorpick.html | 6 +- templates/fields/datagroup.html | 8 +- templates/fields/date.html | 8 +- templates/fields/datetime.html | 6 +- templates/fields/fileupload.html | 6 +- templates/fields/label.html | 6 +- templates/fields/placeholder.html | 6 +- templates/fields/select.html | 6 +- templates/fields/select2.html | 6 +- templates/fields/select2multi.html | 6 +- templates/fields/signature.html | 6 +- templates/fields/simplemde.html | 6 +- templates/fields/text.html | 8 +- templates/fields/textarea.html | 8 +- templates/fields/time.html | 6 +- templates/fields/tinymce.html | 6 +- templates/form_template.html | 4 +- test/TestTemplate.php | 6 +- test/unit/LanguageManagerUnit.php | 22 +- 38 files changed, 11401 insertions(+), 14426 deletions(-) delete mode 100644 lang/de-ext.po delete mode 100644 lang/en-ext.po delete mode 100644 lang/hi.po delete mode 100644 lang/si.po create mode 100644 migrations/v20180305_210100_drop_si_hi_languages.php diff --git a/api/Base.js b/api/Base.js index 5c42c471..71c848b2 100644 --- a/api/Base.js +++ b/api/Base.js @@ -27,20 +27,20 @@ Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilin * @class Base.js */ function IceHRMBase() { - this.deleteParams = {}; - this.createRemoteTable = false; - this.instanceId = "None"; - this.ga = []; - this.showEdit = true; - this.showDelete = true; - this.showSave = true; - this.showCancel = true; - this.showFormOnPopup = false; - this.filtersAlreadySet = false; - this.currentFilterString = ""; + this.deleteParams = {}; + this.createRemoteTable = false; + this.instanceId = "None"; + this.ga = []; + this.showEdit = true; + this.showDelete = true; + this.showSave = true; + this.showCancel = true; + this.showFormOnPopup = false; + this.filtersAlreadySet = false; + this.currentFilterString = ""; this.sorting = 0; - this.settings = {}; - this.translations = {}; + this.settings = {}; + this.translations = {}; } this.fieldTemplates = null; @@ -71,16 +71,16 @@ IceHRMBase.method('init' , function(appName, currentView, dataUrl, permissions) * @param val {Boolean} */ IceHRMBase.method('setNoJSONRequests' , function(val) { - this.noJSONRequests = val; + this.noJSONRequests = val; }); IceHRMBase.method('setPermissions' , function(permissions) { - this.permissions = permissions; + this.permissions = permissions; }); IceHRMBase.method('sortingStarted' , function(val) { - this.sorting = val; + this.sorting = val; }); /** @@ -91,85 +91,85 @@ IceHRMBase.method('sortingStarted' , function(val) { * this.checkPermission("Upload/Delete Profile Image") */ IceHRMBase.method('checkPermission' , function(permission) { - if(this.permissions[permission] == undefined || this.permissions[permission] == null || this.permissions[permission] == "Yes"){ - return "Yes"; - }else{ - return this.permissions[permission]; - } + if(this.permissions[permission] == undefined || this.permissions[permission] == null || this.permissions[permission] == "Yes"){ + return "Yes"; + }else{ + return this.permissions[permission]; + } }); IceHRMBase.method('setBaseUrl' , function(url) { - this.baseUrl = url; + this.baseUrl = url; }); IceHRMBase.method('setUser' , function(user) { - this.user = user; + this.user = user; }); IceHRMBase.method('getUser' , function() { - return this.user; + return this.user; }); IceHRMBase.method('setInstanceId' , function(id) { - this.instanceId = id; + this.instanceId = id; }); IceHRMBase.method('setGoogleAnalytics' , function(ga) { - this.ga = ga; + this.ga = ga; }); IceHRMBase.method('scrollToTop' , function() { - $("html, body").animate({ scrollTop: 0 }, "fast"); + $("html, body").animate({ scrollTop: 0 }, "fast"); }); IceHRMBase.method('scrollToBottom' , function() { - $("html, body").animate({ scrollTop: $(document).height() }, "slow"); + $("html, body").animate({ scrollTop: $(document).height() }, "slow"); }); IceHRMBase.method('scrollToElement' , function(element) { - if($(window).height() <= element.offset().top){ - $("html, body").animate({ scrollTop: element.offset().top }, "slow"); - } + if($(window).height() <= element.offset().top){ + $("html, body").animate({ scrollTop: element.offset().top }, "slow"); + } }); IceHRMBase.method('scrollToElementBottom' , function(element) { - if($(window).height() <= element.offset().top + element.height()){ - $("html, body").animate({ scrollTop: element.offset().top + element.height() }, "slow"); - } + if($(window).height() <= element.offset().top + element.height()){ + $("html, body").animate({ scrollTop: element.offset().top + element.height() }, "slow"); + } }); IceHRMBase.method('setTranslations' , function(txt) { - this.translations = txt['messages']['']; + this.translations = txt['messages']['']; }); IceHRMBase.method('gt' , function(key) { - if(this.translations[key] == undefined){ - return key; - } - return this.translations[key][0]; + if(this.translations[key] == undefined){ + return key; + } + return this.translations[key][0]; }); IceHRMBase.method('addToLangTerms' , function(key) { - var termsArr; - var terms = localStorage.getItem("terms"); - if(terms == undefined){ - termsArr = {}; - }else{ - try{ - termsArr = JSON.parse(terms); - }catch(e){ - termsArr = {}; - } + var termsArr; + var terms = localStorage.getItem("terms"); + if(terms == undefined){ + termsArr = {}; + }else{ + try{ + termsArr = JSON.parse(terms); + }catch(e){ + termsArr = {}; + } - } + } - if(this.translations[key] == undefined){ - termsArr[key] = key; - localStorage.setItem("terms", JSON.stringify(termsArr)); - } + if(this.translations[key] == undefined){ + termsArr[key] = key; + localStorage.setItem("terms", JSON.stringify(termsArr)); + } }); /** @@ -183,28 +183,28 @@ IceHRMBase.method('addToLangTerms' , function(key) { * }); */ IceHRMBase.method('showActionButtons' , function() { - return true; + return true; }); IceHRMBase.method('trackEvent' , function(action, label, value) { - try{ - if(label == undefined || label == null){ - this.ga.push(['_trackEvent', this.instanceId, action]); - }else if(value == undefined || value == null){ - this.ga.push(['_trackEvent', this.instanceId, action, label]); - }else{ - this.ga.push(['_trackEvent', this.instanceId, action, label, value]); - } - }catch(e){ + try{ + if(label == undefined || label == null){ + this.ga.push(['_trackEvent', this.instanceId, action]); + }else if(value == undefined || value == null){ + this.ga.push(['_trackEvent', this.instanceId, action, label]); + }else{ + this.ga.push(['_trackEvent', this.instanceId, action, label, value]); + } + }catch(e){ - } + } }); IceHRMBase.method('setCurrentProfile' , function(currentProfile) { - this.currentProfile = currentProfile; + this.currentProfile = currentProfile; }); /** @@ -214,7 +214,7 @@ IceHRMBase.method('setCurrentProfile' , function(currentProfile) { */ IceHRMBase.method('getCurrentProfile' , function() { - return this.currentProfile; + return this.currentProfile; }); /** @@ -233,72 +233,72 @@ IceHRMBase.method('getCurrentProfile' , function() { * }); */ IceHRMBase.method('initFieldMasterData' , function(callback, loadAllCallback, loadAllCallbackData) { - var values; - if(this.showAddNew == undefined || this.showAddNew == null){ - this.showAddNew = true; - } - this.fieldMasterData = {}; - this.fieldMasterDataKeys = {}; - this.fieldMasterDataCallback = loadAllCallback; - this.fieldMasterDataCallbackData = loadAllCallbackData; - this.sourceMapping = {}; - var fields = this.getFormFields(); - var filterFields = this.getFilters(); + var values; + if(this.showAddNew == undefined || this.showAddNew == null){ + this.showAddNew = true; + } + this.fieldMasterData = {}; + this.fieldMasterDataKeys = {}; + this.fieldMasterDataCallback = loadAllCallback; + this.fieldMasterDataCallbackData = loadAllCallbackData; + this.sourceMapping = {}; + var fields = this.getFormFields(); + var filterFields = this.getFilters(); - if(filterFields != null){ - for(var j=0;j'; - } + var html = ""; + if(this.getShowAddNew()){ + html = ''; + } - if(this.getFilters() != null){ - if(html != ""){ - html += "  "; - } - html+=''; - html += "  "; - if(this.filtersAlreadySet){ - html+=''; - }else{ - html+=''; - } + if(this.getFilters() != null){ + if(html != ""){ + html += "  "; + } + html+=''; + html += "  "; + if(this.filtersAlreadySet){ + html+=''; + }else{ + html+=''; + } - } + } - html = html.replace(/__id__/g, this.getTableName()); + html = html.replace(/__id__/g, this.getTableName()); - if(this.currentFilterString != "" && this.currentFilterString != null){ - html = html.replace(/__filterString__/g, this.currentFilterString); - }else{ - html = html.replace(/__filterString__/g, 'Reset Filters'); - } + if(this.currentFilterString != "" && this.currentFilterString != null){ + html = html.replace(/__filterString__/g, this.currentFilterString); + }else{ + html = html.replace(/__filterString__/g, 'Reset Filters'); + } - if(html != ""){ - html = '
'+html+'
'; - } + if(html != ""){ + html = '
'+html+'
'; + } - return html; + return html; }); @@ -595,76 +595,76 @@ IceHRMBase.method('createTable', function(elementId) { var that = this; - if(this.getRemoteTable()){ - this.createTableServer(elementId); - return; - } + if(this.getRemoteTable()){ + this.createTableServer(elementId); + return; + } - var headers = this.getHeaders(); + var headers = this.getHeaders(); - //add translations - for(index in headers){ - headers[index].sTitle = this.gt(headers[index].sTitle); - } + //add translations + for(index in headers){ + headers[index].sTitle = this.gt(headers[index].sTitle); + } - var data = this.getTableData(); + var data = this.getTableData(); - if(this.showActionButtons()){ + if(this.showActionButtons()){ headers.push(this.getActionButtonHeader()); - } + } - if(this.showActionButtons()){ - for(var i=0;i
'; - }else{ - html = '
'; - } - */ - //Find current page - var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); - var start = 0; - if(activePage != undefined && activePage != null){ - start = parseInt(activePage, 10)*15 - 15; - } + var html = ""; + html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); + /* + if(this.getShowAddNew()){ + html = this.getTableTopButtonHtml()+'
'; + }else{ + html = '
'; + } + */ + //Find current page + var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); + var start = 0; + if(activePage != undefined && activePage != null){ + start = parseInt(activePage, 10)*15 - 15; + } - $('#'+elementId).html(html); + $('#'+elementId).html(html); - var dataTableParams = { - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - }, - "aaData": data, - "aoColumns": headers, - "bSort": that.isSortable(), - "iDisplayLength": 15, - "iDisplayStart": start - }; + var dataTableParams = { + "oLanguage": { + "sLengthMenu": "_MENU_ records per page" + }, + "aaData": data, + "aoColumns": headers, + "bSort": that.isSortable(), + "iDisplayLength": 15, + "iDisplayStart": start + }; - var customTableParams = this.getCustomTableParams(); + var customTableParams = this.getCustomTableParams(); - $.extend(dataTableParams, customTableParams); + $.extend(dataTableParams, customTableParams); - $('#'+elementId+' #grid').dataTable( dataTableParams ); + $('#'+elementId+' #grid').dataTable( dataTableParams ); - $(".dataTables_paginate ul").addClass("pagination"); - $(".dataTables_length").hide(); - $(".dataTables_filter input").addClass("form-control"); - $(".dataTables_filter input").attr("placeholder","Search"); - $(".dataTables_filter label").contents().filter(function(){ - return (this.nodeType == 3); - }).remove(); - $('.tableActionButton').tooltip(); + $(".dataTables_paginate ul").addClass("pagination"); + $(".dataTables_length").hide(); + $(".dataTables_filter input").addClass("form-control"); + $(".dataTables_filter input").attr("placeholder","Search"); + $(".dataTables_filter label").contents().filter(function(){ + return (this.nodeType == 3); + }).remove(); + $('.tableActionButton').tooltip(); }); /** @@ -674,74 +674,74 @@ IceHRMBase.method('createTable', function(elementId) { */ IceHRMBase.method('createTableServer', function(elementId) { - var that = this; - var headers = this.getHeaders(); + var that = this; + var headers = this.getHeaders(); - headers.push({ "sTitle": "", "sClass": "center" }); + headers.push({ "sTitle": "", "sClass": "center" }); - //add translations - for(index in headers){ - headers[index].sTitle = this.gt(headers[index].sTitle); - } + //add translations + for(index in headers){ + headers[index].sTitle = this.gt(headers[index].sTitle); + } - var html = ""; - html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); - /* - if(this.getShowAddNew()){ - html = this.getTableTopButtonHtml()+'
'; - }else{ - html = '
'; - } - */ + var html = ""; + html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); + /* + if(this.getShowAddNew()){ + html = this.getTableTopButtonHtml()+'
'; + }else{ + html = '
'; + } + */ - //Find current page - var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); - var start = 0; - if(activePage != undefined && activePage != null){ - start = parseInt(activePage, 10)*15 - 15; - } + //Find current page + var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); + var start = 0; + if(activePage != undefined && activePage != null){ + start = parseInt(activePage, 10)*15 - 15; + } - $('#'+elementId).html(html); + $('#'+elementId).html(html); - var dataTableParams = { - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - }, - "bProcessing": true, - "bServerSide": true, - "sAjaxSource": that.getDataUrl(that.getDataMapping()), - "aoColumns": headers, - "bSort": that.isSortable(), - "parent":that, - "iDisplayLength": 15, - "iDisplayStart": start - }; + var dataTableParams = { + "oLanguage": { + "sLengthMenu": "_MENU_ records per page" + }, + "bProcessing": true, + "bServerSide": true, + "sAjaxSource": that.getDataUrl(that.getDataMapping()), + "aoColumns": headers, + "bSort": that.isSortable(), + "parent":that, + "iDisplayLength": 15, + "iDisplayStart": start + }; - if(this.showActionButtons()){ - dataTableParams["aoColumnDefs"] = [ - { - "fnRender": that.getActionButtons, - "aTargets": [that.getDataMapping().length] - } - ]; - } + if(this.showActionButtons()){ + dataTableParams["aoColumnDefs"] = [ + { + "fnRender": that.getActionButtons, + "aTargets": [that.getDataMapping().length] + } + ]; + } - var customTableParams = this.getCustomTableParams(); + var customTableParams = this.getCustomTableParams(); - $.extend(dataTableParams, customTableParams); + $.extend(dataTableParams, customTableParams); - $('#'+elementId+' #grid').dataTable( dataTableParams ); + $('#'+elementId+' #grid').dataTable( dataTableParams ); - $(".dataTables_paginate ul").addClass("pagination"); - $(".dataTables_length").hide(); - $(".dataTables_filter input").addClass("form-control"); - $(".dataTables_filter input").attr("placeholder","Search"); - $(".dataTables_filter label").contents().filter(function(){ - return (this.nodeType == 3); - }).remove(); + $(".dataTables_paginate ul").addClass("pagination"); + $(".dataTables_length").hide(); + $(".dataTables_filter input").addClass("form-control"); + $(".dataTables_filter input").attr("placeholder","Search"); + $(".dataTables_filter label").contents().filter(function(){ + return (this.nodeType == 3); + }).remove(); - $('.tableActionButton').tooltip(); + $('.tableActionButton').tooltip(); }); @@ -749,7 +749,7 @@ IceHRMBase.method('createTableServer', function(elementId) { * This should be overridden in module lib.js classes to return module headers which are used to create the data table. * @method getHeaders * @example - SettingAdapter.method('getHeaders', function() { + SettingAdapter.method('getHeaders', function() { return [ { "sTitle": "ID" ,"bVisible":false}, { "sTitle": "Name" }, @@ -767,7 +767,7 @@ IceHRMBase.method('getHeaders', function() { * This should be overridden in module lib.js classes to return module field values which are used to create the data table. * @method getDataMapping * @example - SettingAdapter.method('getDataMapping', function() { + SettingAdapter.method('getDataMapping', function() { return [ "id", "name", @@ -785,7 +785,7 @@ IceHRMBase.method('getDataMapping', function() { * This should be overridden in module lib.js classes to return module from fields which are used to create the add/edit form and also used for initializing select box values in form. * @method getFormFields * @example - SettingAdapter.method('getFormFields', function() { + SettingAdapter.method('getFormFields', function() { return [ [ "id", {"label":"ID","type":"hidden"}], [ "value", {"label":"Value","type":"text","validation":"none"}] @@ -804,7 +804,7 @@ IceHRMBase.method('getTableData', function() { * This can be overridden in module lib.js classes inorder to show a filter form * @method getFilters * @example - EmployeeAdapter.method('getFilters', function() { + EmployeeAdapter.method('getFilters', function() { return [ [ "job_title", {"label":"Job Title","type":"select2","allow-null":true,"null-label":"All Job Titles","remote-source":["JobTitle","id","name"]}], [ "department", {"label":"Department","type":"select2","allow-null":true,"null-label":"All Departments","remote-source":["CompanyStructure","id","title"]}], @@ -813,7 +813,7 @@ IceHRMBase.method('getTableData', function() { }); */ IceHRMBase.method('getFilters', function() { - return null; + return null; }); /** @@ -822,23 +822,23 @@ IceHRMBase.method('getFilters', function() { * @param id {int} id of the item to edit */ IceHRMBase.method('edit', function(id) { - this.currentId = id; - this.getElement(id,[]); + this.currentId = id; + this.getElement(id,[]); }); IceHRMBase.method('copyRow', function(id) { - this.getElement(id,[],true); + this.getElement(id,[],true); }); IceHRMBase.method('renderModel', function(id,header,body) { - $('#'+id+'ModelBody').html(""); + $('#'+id+'ModelBody').html(""); - if(body == undefined || body == null){ - body = ""; - } + if(body == undefined || body == null){ + body = ""; + } - $('#'+id+'ModelLabel').html(header); - $('#'+id+'ModelBody').html(body); + $('#'+id+'ModelLabel').html(header); + $('#'+id+'ModelBody').html(body); }); @@ -874,15 +874,15 @@ IceHRMBase.method('renderYesNoModel', function(header,body,yesBtnName,noBtnName, }); IceHRMBase.method('renderModelFromDom', function(id,header,element) { - $('#'+id+'ModelBody').html(""); + $('#'+id+'ModelBody').html(""); - if(element == undefined || element == null){ - element = $("
"); - } + if(element == undefined || element == null){ + element = $("
"); + } - $('#'+id+'ModelLabel').html(header); - $('#'+id+'ModelBody').html(""); - $('#'+id+'ModelBody').append(element); + $('#'+id+'ModelLabel').html(header); + $('#'+id+'ModelBody').html(""); + $('#'+id+'ModelBody').append(element); }); /** @@ -892,9 +892,9 @@ IceHRMBase.method('renderModelFromDom', function(id,header,element) { */ IceHRMBase.method('deleteRow', function(id) { - this.deleteParams['id'] = id; - this.renderModel('delete',"Confirm Deletion","Are you sure you want to delete this item ?"); - $('#deleteModel').modal('show'); + this.deleteParams['id'] = id; + this.renderModel('delete',"Confirm Deletion","Are you sure you want to delete this item ?"); + $('#deleteModel').modal('show'); }); @@ -910,74 +910,74 @@ IceHRMBase.method('deleteRow', function(id) { * this.showMessage("Error Occured while Applying Leave", callBackData); */ IceHRMBase.method('showMessage', function(title,message,closeCallback,closeCallbackData, isPlain) { - var that = this; - var modelId = ""; - if(isPlain){ - modelId = "#plainMessageModel"; - this.renderModel('plainMessage',title,message); - }else{ - modelId = "#messageModel"; - this.renderModel('message',title,message); - } + var that = this; + var modelId = ""; + if(isPlain){ + modelId = "#plainMessageModel"; + this.renderModel('plainMessage',title,message); + }else{ + modelId = "#messageModel"; + this.renderModel('message',title,message); + } - $(modelId).unbind('hide'); - if(closeCallback != null && closeCallback != undefined){ - $(modelId).on('hidden.bs.modal',function(){ - closeCallback.apply(that,closeCallbackData); - $(modelId).unbind('hidden.bs.modal'); - }); - } - $(modelId).modal({ - backdrop: 'static' - }); + $(modelId).unbind('hide'); + if(closeCallback != null && closeCallback != undefined){ + $(modelId).on('hidden.bs.modal',function(){ + closeCallback.apply(that,closeCallbackData); + $(modelId).unbind('hidden.bs.modal'); + }); + } + $(modelId).modal({ + backdrop: 'static' + }); }); IceHRMBase.method('showDomElement', function(title,element,closeCallback,closeCallbackData, isPlain) { - var that = this; - var modelId = ""; - if(isPlain){ - modelId = "#dataMessageModel"; - this.renderModelFromDom('dataMessage',title,element); - }else{ - modelId = "#messageModel"; - this.renderModelFromDom('message',title,element); - } + var that = this; + var modelId = ""; + if(isPlain){ + modelId = "#dataMessageModel"; + this.renderModelFromDom('dataMessage',title,element); + }else{ + modelId = "#messageModel"; + this.renderModelFromDom('message',title,element); + } - $(modelId).unbind('hide'); - if(closeCallback != null && closeCallback != undefined){ - $(modelId).on('hidden.bs.modal',function(){ - closeCallback.apply(that,closeCallbackData); - $(modelId).unbind('hidden.bs.modal'); - }); - } - $(modelId).modal({ - backdrop: 'static' - }); + $(modelId).unbind('hide'); + if(closeCallback != null && closeCallback != undefined){ + $(modelId).on('hidden.bs.modal',function(){ + closeCallback.apply(that,closeCallbackData); + $(modelId).unbind('hidden.bs.modal'); + }); + } + $(modelId).modal({ + backdrop: 'static' + }); }); IceHRMBase.method('confirmDelete', function() { - if(this.deleteParams['id'] != undefined || this.deleteParams['id'] != null){ - this.deleteObj(this.deleteParams['id'],[]); - } - $('#deleteModel').modal('hide'); + if(this.deleteParams['id'] != undefined || this.deleteParams['id'] != null){ + this.deleteObj(this.deleteParams['id'],[]); + } + $('#deleteModel').modal('hide'); }); IceHRMBase.method('cancelDelete', function() { - $('#deleteModel').modal('hide'); - this.deleteParams['id'] = null; + $('#deleteModel').modal('hide'); + this.deleteParams['id'] = null; }); IceHRMBase.method('closeMessage', function() { - $('#messageModel').modal('hide'); + $('#messageModel').modal('hide'); }); IceHRMBase.method('cancelYesno', function() { - $('#yesnoModel').modal('hide'); + $('#yesnoModel').modal('hide'); }); IceHRMBase.method('closePlainMessage', function() { - $('#plainMessageModel').modal('hide'); - $('#dataMessageModel').modal('hide'); + $('#plainMessageModel').modal('hide'); + $('#dataMessageModel').modal('hide'); }); IceHRMBase.method('closeDataMessage', function() { @@ -993,36 +993,37 @@ IceHRMBase.method('closeDataMessage', function() { */ IceHRMBase.method('save', function(callGetFunction, successCallback) { - var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); - params = this.forceInjectValuesBeforeSave(params); - var msg = this.doCustomValidation(params); - if(msg == null){ - var id = $('#'+this.getTableName()+"_submit #id").val(); - if(id != null && id != undefined && id != ""){ - $(params).attr('id',id); - } - params = this.makeEmptyDateFieldsNull(params); - this.add(params,[],callGetFunction, successCallback); - }else{ - $("#"+this.getTableName()+'Form .label').html(msg); - $("#"+this.getTableName()+'Form .label').show(); - } + var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"}); + if(validator.checkValues()){ + var params = validator.getFormParameters(); + params = this.forceInjectValuesBeforeSave(params); + var msg = this.doCustomValidation(params); + if(msg == null){ + var id = $('#'+this.getTableName()+"_submit #id").val(); + if(id != null && id != undefined && id != ""){ + $(params).attr('id',id); + } + params = this.makeEmptyDateFieldsNull(params); + this.add(params,[],callGetFunction, successCallback); + }else{ + $("#"+this.getTableName()+'Form .label').html(msg); + $("#"+this.getTableName()+'Form .label').show(); + this.scrollToTop(); + } - } + } }); IceHRMBase.method('makeEmptyDateFieldsNull', function(params) { - var fields = this.getFormFields(); - fields.forEach(function(field) { - if((field[1].type == 'date' || field[1].type == 'datetime') - && (params[field[0]] === '' || params[field[0]] === '0000-00-00' || params[field[0]] === '0000-00-00 00:00:00')){ - delete params[field[0]]; - } - }); - return params; + var fields = this.getFormFields(); + fields.forEach(function(field) { + if((field[1].type == 'date' || field[1].type == 'datetime') + && (params[field[0]] === '' || params[field[0]] === '0000-00-00' || params[field[0]] === '0000-00-00 00:00:00')){ + delete params[field[0]]; + } + }); + return params; }); /** @@ -1032,7 +1033,7 @@ IceHRMBase.method('makeEmptyDateFieldsNull', function(params) { * @returns {Array} modified parameters */ IceHRMBase.method('forceInjectValuesBeforeSave', function(params) { - return params; + return params; }); /** @@ -1041,7 +1042,7 @@ IceHRMBase.method('forceInjectValuesBeforeSave', function(params) { * @param params {Array} keys and values in form * @returns {Null or String} return null if validation success, returns error message if unsuccessful * @example - EmployeeLeaveAdapter.method('doCustomValidation', function(params) { + EmployeeLeaveAdapter.method('doCustomValidation', function(params) { try{ if(params['date_start'] != params['date_end']){ var ds = new Date(params['date_start']); @@ -1057,125 +1058,125 @@ IceHRMBase.method('forceInjectValuesBeforeSave', function(params) { }); */ IceHRMBase.method('doCustomValidation', function(params) { - return null; + return null; }); IceHRMBase.method('filterQuery', function() { - var validator = new FormValidation(this.getTableName()+"_filter",true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); - if(this.doCustomFilterValidation(params)){ + var validator = new FormValidation(this.getTableName()+"_filter",true,{'ShowPopup':false,"LabelErrorClass":"error"}); + if(validator.checkValues()){ + var params = validator.getFormParameters(); + if(this.doCustomFilterValidation(params)){ - //remove null params - for (var prop in params) { - if(params.hasOwnProperty(prop)){ - if(params[prop] == "NULL"){ - delete(params[prop]); - } - } - } + //remove null params + for (var prop in params) { + if(params.hasOwnProperty(prop)){ + if(params[prop] == "NULL"){ + delete(params[prop]); + } + } + } - this.setFilter(params); - this.filtersAlreadySet = true; - $("#"+this.getTableName()+"_resetFilters").show(); - this.currentFilterString = this.getFilterString(params); + this.setFilter(params); + this.filtersAlreadySet = true; + $("#"+this.getTableName()+"_resetFilters").show(); + this.currentFilterString = this.getFilterString(params); - this.get([]); - this.closePlainMessage(); - } + this.get([]); + this.closePlainMessage(); + } - } + } }); IceHRMBase.method('getFilterString', function(filters) { - var str = ''; - var rmf, source, values, select2MVal, value, valueOrig; + var str = ''; + var rmf, source, values, select2MVal, value, valueOrig; - var filterFields = this.getFilters(); + var filterFields = this.getFilters(); - if(values == null){ - values = []; - } + if(values == null){ + values = []; + } - for (var prop in filters) { - if(filters.hasOwnProperty(prop)){ - values = this.getMetaFieldValues(prop,filterFields); - value = ""; - valueOrig = null; + for (var prop in filters) { + if(filters.hasOwnProperty(prop)){ + values = this.getMetaFieldValues(prop,filterFields); + value = ""; + valueOrig = null; - if((values['type'] == 'select' || values['type'] == 'select2')){ + if((values['type'] == 'select' || values['type'] == 'select2')){ - if(values['remote-source']!= undefined && values['remote-source']!= null){ - rmf = values['remote-source']; - if(filters[prop] == "NULL"){ - if(values['null-label'] != undefined && values['null-label'] != null){ - value = values['null-label']; - }else{ - value = "Not Selected"; - } - }else{ - value = this.fieldMasterData[rmf[0]+"_"+rmf[1]+"_"+rmf[2]][filters[prop]]; - valueOrig = value; - } + if(values['remote-source']!= undefined && values['remote-source']!= null){ + rmf = values['remote-source']; + if(filters[prop] == "NULL"){ + if(values['null-label'] != undefined && values['null-label'] != null){ + value = values['null-label']; + }else{ + value = "Not Selected"; + } + }else{ + value = this.fieldMasterData[rmf[0]+"_"+rmf[1]+"_"+rmf[2]][filters[prop]]; + valueOrig = value; + } - }else{ - source = values['source'][0]; - if(filters[prop] == "NULL"){ - if(values['null-label'] != undefined && values['null-label'] != null){ - value = values['null-label']; - }else{ - value = "Not Selected"; - } - }else{ - for(var i=0; i'); - $tempDomObj.attr('id',randomFormId); + var $tempDomObj; + var randomFormId = this.generateRandom(14); + $tempDomObj = $('
'); + $tempDomObj.attr('id',randomFormId); - $tempDomObj.html(formHtml); + $tempDomObj.html(formHtml); - $tempDomObj.find('.datefield').datepicker({'viewMode':2}); - $tempDomObj.find('.timefield').datetimepicker({ - language: 'en', - pickDate: false + $tempDomObj.find('.datefield').datepicker({'viewMode':2}); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false }); - $tempDomObj.find('.datetimefield').datetimepicker({ - language: 'en' + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en' }); - $tempDomObj.find('.colorpick').colorpicker(); - tinymce.init({ - selector: '#'+$tempDomObj.attr('id')+' .tinymce', - height: "400" - }); + $tempDomObj.find('.colorpick').colorpicker(); + tinymce.init({ + selector: '#'+$tempDomObj.attr('id')+' .tinymce', + height: "400" + }); - $tempDomObj.find('.simplemde').each(function() { - var simplemde = new SimpleMDE({ element: $(this)[0] }); - $(this).data('simplemde', simplemde); - //simplemde.value($(this).val()); - }); + $tempDomObj.find('.simplemde').each(function() { + var simplemde = new SimpleMDE({ element: $(this)[0] }); + $(this).data('simplemde', simplemde); + //simplemde.value($(this).val()); + }); - //$tempDomObj.find('.select2Field').select2(); - $tempDomObj.find('.select2Field').each(function() { - $(this).select2().select2('val', $(this).find("option:eq(0)").val()); - }); + //$tempDomObj.find('.select2Field').select2(); + $tempDomObj.find('.select2Field').each(function() { + $(this).select2().select2('val', $(this).find("option:eq(0)").val()); + }); - $tempDomObj.find('.select2Multi').each(function() { - $(this).select2().on("change",function(e){ - var parentRow = $(this).parents(".row"); - var height = parentRow.find(".select2-choices").height(); - parentRow.height(parseInt(height)); - }); - }); + $tempDomObj.find('.select2Multi').each(function() { + $(this).select2().on("change",function(e){ + var parentRow = $(this).parents(".row"); + var height = parentRow.find(".select2-choices").height(); + parentRow.height(parseInt(height)); + }); + }); /* $tempDomObj.find('.signatureField').each(function() { @@ -1275,23 +1276,23 @@ IceHRMBase.method('showFilters', function(object) { }); */ - //var tHtml = $tempDomObj.wrap('
').parent().html(); - this.showDomElement("Edit",$tempDomObj,null,null,true); - $(".filterBtn").off(); - $(".filterBtn").on('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - try{ - modJs.filterQuery(); + //var tHtml = $tempDomObj.wrap('
').parent().html(); + this.showDomElement("Edit",$tempDomObj,null,null,true); + $(".filterBtn").off(); + $(".filterBtn").on('click',function(e) { + e.preventDefault(); + e.stopPropagation(); + try{ + modJs.filterQuery(); - }catch(e){ - }; - return false; - }); + }catch(e){ + }; + return false; + }); - if(this.filter != undefined && this.filter != null){ - this.fillForm(this.filter,"#"+this.getTableName()+"_filter", this.getFilters()); - } + if(this.filter != undefined && this.filter != null){ + this.fillForm(this.filter,"#"+this.getTableName()+"_filter", this.getFilters()); + } }); @@ -1314,85 +1315,85 @@ IceHRMBase.method('preRenderForm', function(object) { IceHRMBase.method('renderForm', function(object) { - var that = this; + var that = this; var signatureIds = []; - if(object == null || object == undefined){ - this.currentId = null; - } + if(object == null || object == undefined){ + this.currentId = null; + } - this.preRenderForm(object); + this.preRenderForm(object); - var formHtml = this.templates['formTemplate']; - var html = ""; - var fields = this.getFormFields(); + var formHtml = this.templates['formTemplate']; + var html = ""; + var fields = this.getFormFields(); - for(var i=0;i
'); - $tempDomObj.attr('id',randomFormId); + var $tempDomObj; + var randomFormId = this.generateRandom(14); + if(!this.showFormOnPopup){ + $tempDomObj = $("#"+this.getTableName()+'Form'); + }else{ + $tempDomObj = $('
'); + $tempDomObj.attr('id',randomFormId); - } + } - $tempDomObj.html(formHtml); + $tempDomObj.html(formHtml); - $tempDomObj.find('.datefield').datepicker({'viewMode':2}); - $tempDomObj.find('.timefield').datetimepicker({ - language: 'en', - pickDate: false + $tempDomObj.find('.datefield').datepicker({'viewMode':2}); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false }); - $tempDomObj.find('.datetimefield').datetimepicker({ - language: 'en' + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en' }); - $tempDomObj.find('.colorpick').colorpicker(); + $tempDomObj.find('.colorpick').colorpicker(); - tinymce.init({ - selector: '#'+$tempDomObj.attr('id')+' .tinymce', - height: "400" - }); + tinymce.init({ + selector: '#'+$tempDomObj.attr('id')+' .tinymce', + height: "400" + }); - $tempDomObj.find('.simplemde').each(function() { - var simplemde = new SimpleMDE({ element: $(this)[0] }); - $(this).data('simplemde', simplemde); - //simplemde.value($(this).val()); - }); + $tempDomObj.find('.simplemde').each(function() { + var simplemde = new SimpleMDE({ element: $(this)[0] }); + $(this).data('simplemde', simplemde); + //simplemde.value($(this).val()); + }); - //$tempDomObj.find('.select2Field').select2(); - $tempDomObj.find('.select2Field').each(function() { - $(this).select2().select2('val', $(this).find("option:eq(0)").val()); + //$tempDomObj.find('.select2Field').select2(); + $tempDomObj.find('.select2Field').each(function() { + $(this).select2().select2('val', $(this).find("option:eq(0)").val()); - }); + }); - $tempDomObj.find('.select2Multi').each(function() { - $(this).select2().on("change",function(e){ - var parentRow = $(this).parents(".row"); - var height = parentRow.find(".select2-choices").height(); - parentRow.height(parseInt(height)); - }); + $tempDomObj.find('.select2Multi').each(function() { + $(this).select2().on("change",function(e){ + var parentRow = $(this).parents(".row"); + var height = parentRow.find(".select2-choices").height(); + parentRow.height(parseInt(height)); + }); - }); + }); $tempDomObj.find('.signatureField').each(function() { @@ -1400,84 +1401,84 @@ IceHRMBase.method('renderForm', function(object) { signatureIds.push($(this).attr('id')); }); - for(var i=0;i').parent().html(); - //this.showMessage("Edit",tHtml,null,null,true); - this.showMessage("Edit","",null,null,true); + //var tHtml = $tempDomObj.wrap('
').parent().html(); + //this.showMessage("Edit",tHtml,null,null,true); + this.showMessage("Edit","",null,null,true); - $("#plainMessageModel .modal-body").html(""); - $("#plainMessageModel .modal-body").append($tempDomObj); + $("#plainMessageModel .modal-body").html(""); + $("#plainMessageModel .modal-body").append($tempDomObj); for(var i=0;i
  • '; - editButton = '
  • '; + deleteButton = '
  • '; + editButton = '
  • '; - template = field[1]['html']; + template = field[1]['html']; - if(data != null && data != undefined && field[1]['sort-function'] != undefined && field[1]['sort-function'] != null){ - data.sort(field[1]['sort-function']); - } + if(data != null && data != undefined && field[1]['sort-function'] != undefined && field[1]['sort-function'] != null){ + data.sort(field[1]['sort-function']); + } - html = $('
    '); + html = $('
    '); - for(i=0;i'); - } - t = t.replace('#_'+key+'_#', itemVal); - } + for(key in item){ + itemVal = item[key]; + if(itemVal != undefined && itemVal != null && typeof itemVal == "string"){ + itemVal = itemVal.replace(/(?:\r\n|\r|\n)/g, '
    '); + } + t = t.replace('#_'+key+'_#', itemVal); + } if(field[1]['render'] != undefined && field[1]['render'] != null){ t = t.replace('#_renderFunction_#', field[1]['render'](item)); } - itemHtml = $(t); - itemHtml.attr('fieldId',field[0]+"_div"); - html.append(itemHtml); - } + itemHtml = $(t); + itemHtml.attr('fieldId',field[0]+"_div"); + html.append(itemHtml); + } - return html; + return html; }); /** @@ -1570,70 +1571,70 @@ IceHRMBase.method('dataGroupToHtml', function(val, field) { * @param field {Array} field meta data */ IceHRMBase.method('resetDataGroup', function(field) { - $("#"+field[0]).val(""); - $("#"+field[0]+"_div").html(""); + $("#"+field[0]).val(""); + $("#"+field[0]+"_div").html(""); }); IceHRMBase.method('showDataGroup', function(field, object) { - var formHtml = this.templates['datagroupTemplate']; - var html = ""; - var fields = field[1]['form']; + var formHtml = this.templates['datagroupTemplate']; + var html = ""; + var fields = field[1]['form']; - if(object != undefined && object != null && object.id != undefined){ - this.currentDataGroupItemId = object.id; - }else{ - this.currentDataGroupItemId = null; - } + if(object != undefined && object != null && object.id != undefined){ + this.currentDataGroupItemId = object.id; + }else{ + this.currentDataGroupItemId = null; + } - for(var i=0;i
    '); - $tempDomObj.attr('id',randomFormId); + var $tempDomObj; + var randomFormId = this.generateRandom(14); + $tempDomObj = $('
    '); + $tempDomObj.attr('id',randomFormId); - $tempDomObj.html(formHtml); + $tempDomObj.html(formHtml); - $tempDomObj.find('.datefield').datepicker({'viewMode':2}); - $tempDomObj.find('.timefield').datetimepicker({ - language: 'en', - pickDate: false + $tempDomObj.find('.datefield').datepicker({'viewMode':2}); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false }); - $tempDomObj.find('.datetimefield').datetimepicker({ - language: 'en' + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en' }); - $tempDomObj.find('.colorpick').colorpicker(); + $tempDomObj.find('.colorpick').colorpicker(); - tinymce.init({ - selector: '#'+$tempDomObj.attr('id')+' .tinymce', - height: "400" - }); + tinymce.init({ + selector: '#'+$tempDomObj.attr('id')+' .tinymce', + height: "400" + }); - $tempDomObj.find('.simplemde').each(function() { - var simplemde = new SimpleMDE({ element: $(this)[0] }); - $(this).data('simplemde', simplemde); - //simplemde.value($(this).val()); - }); + $tempDomObj.find('.simplemde').each(function() { + var simplemde = new SimpleMDE({ element: $(this)[0] }); + $(this).data('simplemde', simplemde); + //simplemde.value($(this).val()); + }); - $tempDomObj.find('.select2Field').each(function() { - $(this).select2().select2('val', $(this).find("option:eq(0)").val()); - }); + $tempDomObj.find('.select2Field').each(function() { + $(this).select2().select2('val', $(this).find("option:eq(0)").val()); + }); - $tempDomObj.find('.select2Multi').each(function() { - $(this).select2().on("change",function(e){ - var parentRow = $(this).parents(".row"); - var height = parentRow.find(".select2-choices").height(); - parentRow.height(parseInt(height)); - }); - }); + $tempDomObj.find('.select2Multi').each(function() { + $(this).select2().on("change",function(e){ + var parentRow = $(this).parents(".row"); + var height = parentRow.find(".select2-choices").height(); + parentRow.height(parseInt(height)); + }); + }); /* $tempDomObj.find('.signatureField').each(function() { @@ -1641,300 +1642,300 @@ IceHRMBase.method('showDataGroup', function(field, object) { }); */ - this.currentDataGroupField = field; - this.showDomElement("Add "+field[1]['label'],$tempDomObj,null,null,true); + this.currentDataGroupField = field; + this.showDomElement("Add "+field[1]['label'],$tempDomObj,null,null,true); - if(object != undefined && object != null){ - this.fillForm(object,"#"+this.getTableName()+"_field_"+field[0], field[1]['form']); - } + if(object != undefined && object != null){ + this.fillForm(object,"#"+this.getTableName()+"_field_"+field[0], field[1]['form']); + } - $(".groupAddBtn").off(); - if(object != undefined && object != null && object.id != undefined){ - $(".groupAddBtn").on('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - try{ - modJs.editDataGroup(); + $(".groupAddBtn").off(); + if(object != undefined && object != null && object.id != undefined){ + $(".groupAddBtn").on('click',function(e) { + e.preventDefault(); + e.stopPropagation(); + try{ + modJs.editDataGroup(); - }catch(e){ - }; - return false; - }); - }else{ - $(".groupAddBtn").on('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - try{ - modJs.addDataGroup(); + }catch(e){ + }; + return false; + }); + }else{ + $(".groupAddBtn").on('click',function(e) { + e.preventDefault(); + e.stopPropagation(); + try{ + modJs.addDataGroup(); - }catch(e){ - }; - return false; - }); - } + }catch(e){ + }; + return false; + }); + } }); IceHRMBase.method('addDataGroup', function() { - var field = this.currentDataGroupField, tempParams; - $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(""); - $("#"+this.getTableName()+"_field_"+field[0]+"_error").hide(); - var validator = new FormValidation(this.getTableName()+"_field_"+field[0],true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); - if(field[1]['custom-validate-function'] != undefined && field[1]['custom-validate-function'] != null){ - tempParams = field[1]['custom-validate-function'].apply(this,[params]); - if(tempParams['valid']){ - params = tempParams['params']; - }else{ - $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(tempParams['message']); - $("#"+this.getTableName()+"_field_"+field[0]+"_error").show(); - return false; - } - } + var field = this.currentDataGroupField, tempParams; + $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(""); + $("#"+this.getTableName()+"_field_"+field[0]+"_error").hide(); + var validator = new FormValidation(this.getTableName()+"_field_"+field[0],true,{'ShowPopup':false,"LabelErrorClass":"error"}); + if(validator.checkValues()){ + var params = validator.getFormParameters(); + if(field[1]['custom-validate-function'] != undefined && field[1]['custom-validate-function'] != null){ + tempParams = field[1]['custom-validate-function'].apply(this,[params]); + if(tempParams['valid']){ + params = tempParams['params']; + }else{ + $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(tempParams['message']); + $("#"+this.getTableName()+"_field_"+field[0]+"_error").show(); + return false; + } + } - var val = $("#"+field[0]).val(); - if(val == ""){ - val = "[]"; - } - var data = JSON.parse(val); + var val = $("#"+field[0]).val(); + if(val == ""){ + val = "[]"; + } + var data = JSON.parse(val); - params['id'] = field[0]+"_"+this.dataGroupGetNextAutoIncrementId(data); - data.push(params); + params['id'] = field[0]+"_"+this.dataGroupGetNextAutoIncrementId(data); + data.push(params); - if(field[1]['sort-function'] != undefined && field[1]['sort-function'] != null){ - data.sort(field[1]['sort-function']); - } + if(field[1]['sort-function'] != undefined && field[1]['sort-function'] != null){ + data.sort(field[1]['sort-function']); + } - val = JSON.stringify(data); + val = JSON.stringify(data); - var html = this.dataGroupToHtml(val,field); + var html = this.dataGroupToHtml(val,field); - $("#"+field[0]+"_div").html(""); - $("#"+field[0]+"_div").append(html); + $("#"+field[0]+"_div").html(""); + $("#"+field[0]+"_div").append(html); - this.makeDataGroupSortable(field, $("#"+field[0]+"_div_inner")); + this.makeDataGroupSortable(field, $("#"+field[0]+"_div_inner")); - $("#"+field[0]).val(val); - this.orderDataGroup(field); + $("#"+field[0]).val(val); + this.orderDataGroup(field); - this.closeDataMessage(); + this.closeDataMessage(); - this.showMessage("Item Added","This change will be effective only when you save the form"); + this.showMessage("Item Added","This change will be effective only when you save the form"); - } + } }); IceHRMBase.method('nl2br' , function(str, len) { - var t = ""; - try{ - var arr = str.split(" "); - var count = 0; - for(var i=0;i len){ - t += arr[i] + "
    "; - count = 0; - }else{ - t += arr[i] + " "; - } - } - }catch(e){} - return t; + var t = ""; + try{ + var arr = str.split(" "); + var count = 0; + for(var i=0;i len){ + t += arr[i] + "
    "; + count = 0; + }else{ + t += arr[i] + " "; + } + } + }catch(e){} + return t; }); IceHRMBase.method('makeDataGroupSortable', function(field, obj) { - obj.data('field',field); - obj.data('firstSort',true); - obj.sortable({ + obj.data('field',field); + obj.data('firstSort',true); + obj.sortable({ - create:function(){ - $(this).height($(this).height()); - }, + create:function(){ + $(this).height($(this).height()); + }, - 'ui-floating': false, - start: function(e, ui) { - $('#sortable-ul-selector-id').sortable({ - sort: function(event, ui) { - var $target = $(event.target); - if (!/html|body/i.test($target.offsetParent()[0].tagName)) { - var top = event.pageY - $target.offsetParent().offset().top - (ui.helper.outerHeight(true) / 2); - ui.helper.css({'top' : top + 'px'}); - } - } - }); + 'ui-floating': false, + start: function(e, ui) { + $('#sortable-ul-selector-id').sortable({ + sort: function(event, ui) { + var $target = $(event.target); + if (!/html|body/i.test($target.offsetParent()[0].tagName)) { + var top = event.pageY - $target.offsetParent().offset().top - (ui.helper.outerHeight(true) / 2); + ui.helper.css({'top' : top + 'px'}); + } + } + }); - }, - revert: true, - stop: function() { - modJs.orderDataGroup($(this).data('field')); - }, - axis: "y", - scroll: false, - placeholder: "sortable-placeholder", - cursor: "move" - }); + }, + revert: true, + stop: function() { + modJs.orderDataGroup($(this).data('field')); + }, + axis: "y", + scroll: false, + placeholder: "sortable-placeholder", + cursor: "move" + }); }); IceHRMBase.method('orderDataGroup', function(field) { - var newArr = [], id; - var list = $("#"+field[0]+"_div_inner [fieldid='"+field[0]+"_div']"); - var val = $("#"+field[0]).val(); - if(val == ""){ - val = "[]"; - } - var data = JSON.parse(val); - list.each(function(){ - id = $(this).attr('id'); - for(index in data){ - if(data[index].id == id){ - newArr.push(data[index]); - break; - } - } - }); + var newArr = [], id; + var list = $("#"+field[0]+"_div_inner [fieldid='"+field[0]+"_div']"); + var val = $("#"+field[0]).val(); + if(val == ""){ + val = "[]"; + } + var data = JSON.parse(val); + list.each(function(){ + id = $(this).attr('id'); + for(index in data){ + if(data[index].id == id){ + newArr.push(data[index]); + break; + } + } + }); - $("#"+field[0]).val(JSON.stringify(newArr)); + $("#"+field[0]).val(JSON.stringify(newArr)); }); IceHRMBase.method('editDataGroup', function() { - var field = this.currentDataGroupField; - var id = this.currentDataGroupItemId; - var validator = new FormValidation(this.getTableName()+"_field_"+field[0],true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); + var field = this.currentDataGroupField; + var id = this.currentDataGroupItemId; + var validator = new FormValidation(this.getTableName()+"_field_"+field[0],true,{'ShowPopup':false,"LabelErrorClass":"error"}); + if(validator.checkValues()){ + var params = validator.getFormParameters(); - if(field[1]['custom-validate-function'] != undefined && field[1]['custom-validate-function'] != null){ - tempParams = field[1]['custom-validate-function'].apply(this,[params]); - if(tempParams['valid']){ - params = tempParams['params']; - }else{ - $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(tempParams['message']); - $("#"+this.getTableName()+"_field_"+field[0]+"_error").show(); - return false; - } - } + if(field[1]['custom-validate-function'] != undefined && field[1]['custom-validate-function'] != null){ + tempParams = field[1]['custom-validate-function'].apply(this,[params]); + if(tempParams['valid']){ + params = tempParams['params']; + }else{ + $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(tempParams['message']); + $("#"+this.getTableName()+"_field_"+field[0]+"_error").show(); + return false; + } + } - if(this.doCustomFilterValidation(params)){ + if(this.doCustomFilterValidation(params)){ - var val = $("#"+field[0]).val(); - if(val == ""){ - val = "[]"; - } - var data = JSON.parse(val); + var val = $("#"+field[0]).val(); + if(val == ""){ + val = "[]"; + } + var data = JSON.parse(val); - var editVal = {}; - var editValIndex = -1; - var newVals = []; - for(var i=0;i= autoId){ - autoId = parseInt(id) + 1; - } - } + var autoId = 1, id; + for(var i=0;i= autoId){ + autoId = parseInt(id) + 1; + } + } - return autoId; + return autoId; }); IceHRMBase.method('deleteDataGroupItem', function(id) { - var fieldId = id.substring(0,id.lastIndexOf("_")); + var fieldId = id.substring(0,id.lastIndexOf("_")); - var val = $("#"+fieldId).val(); - var data = JSON.parse(val); + var val = $("#"+fieldId).val(); + var data = JSON.parse(val); - var newVal = []; + var newVal = []; - for(var i=0;i'); }catch(e){} - } + } - $(formId + ' #'+fields[i][0]).html(placeHolderVal); - }else if(fields[i][1].type == 'fileupload'){ - if(object[fields[i][0]] != null && object[fields[i][0]] != undefined && object[fields[i][0]] != ""){ - $(formId + ' #'+fields[i][0]).html(object[fields[i][0]]); - $(formId + ' #'+fields[i][0]).attr("val",object[fields[i][0]]); - $(formId + ' #'+fields[i][0]).show(); - $(formId + ' #'+fields[i][0]+"_download").show(); + $(formId + ' #'+fields[i][0]).html(placeHolderVal); + }else if(fields[i][1].type == 'fileupload'){ + if(object[fields[i][0]] != null && object[fields[i][0]] != undefined && object[fields[i][0]] != ""){ + $(formId + ' #'+fields[i][0]).html(object[fields[i][0]]); + $(formId + ' #'+fields[i][0]).attr("val",object[fields[i][0]]); + $(formId + ' #'+fields[i][0]).show(); + $(formId + ' #'+fields[i][0]+"_download").show(); - } - if(fields[i][1].readonly == true){ - $(formId + ' #'+fields[i][0]+"_upload").remove(); - } - }else if(fields[i][1].type == 'select'){ - if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ - object[fields[i][0]] = "NULL"; - } - $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); + } + if(fields[i][1].readonly == true){ + $(formId + ' #'+fields[i][0]+"_upload").remove(); + } + }else if(fields[i][1].type == 'select'){ + if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ + object[fields[i][0]] = "NULL"; + } + $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); - }else if(fields[i][1].type == 'select2'){ - if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ - object[fields[i][0]] = "NULL"; - } - $(formId + ' #'+fields[i][0]).select2('val',object[fields[i][0]]); + }else if(fields[i][1].type == 'select2'){ + if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ + object[fields[i][0]] = "NULL"; + } + $(formId + ' #'+fields[i][0]).select2('val',object[fields[i][0]]); - }else if(fields[i][1].type == 'select2multi'){ - //TODO - SM - if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ - object[fields[i][0]] = "NULL"; - } + }else if(fields[i][1].type == 'select2multi'){ + //TODO - SM + if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ + object[fields[i][0]] = "NULL"; + } - var msVal = []; - if(object[fields[i][0]] != undefined && object[fields[i][0]] != null && object[fields[i][0]] != ""){ - try{ - msVal = JSON.parse(object[fields[i][0]]); - }catch(e){} - } + var msVal = []; + if(object[fields[i][0]] != undefined && object[fields[i][0]] != null && object[fields[i][0]] != ""){ + try{ + msVal = JSON.parse(object[fields[i][0]]); + }catch(e){} + } - $(formId + ' #'+fields[i][0]).select2('val',msVal); - var select2Height = $(formId + ' #'+fields[i][0]).find(".select2-choices").height(); - $(formId + ' #'+fields[i][0]).find(".controls").css('min-height', select2Height+"px"); - $(formId + ' #'+fields[i][0]).css('min-height', select2Height+"px"); + $(formId + ' #'+fields[i][0]).select2('val',msVal); + var select2Height = $(formId + ' #'+fields[i][0]).find(".select2-choices").height(); + $(formId + ' #'+fields[i][0]).find(".controls").css('min-height', select2Height+"px"); + $(formId + ' #'+fields[i][0]).css('min-height', select2Height+"px"); - }else if(fields[i][1].type == 'datagroup'){ - try{ - var html = this.dataGroupToHtml(object[fields[i][0]],fields[i]); - $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); - $(formId + ' #'+fields[i][0]+"_div").html(""); - $(formId + ' #'+fields[i][0]+"_div").append(html); + }else if(fields[i][1].type == 'datagroup'){ + try{ + var html = this.dataGroupToHtml(object[fields[i][0]],fields[i]); + $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); + $(formId + ' #'+fields[i][0]+"_div").html(""); + $(formId + ' #'+fields[i][0]+"_div").append(html); - this.makeDataGroupSortable(fields[i], $(formId + ' #'+fields[i][0]+"_div_inner")); + this.makeDataGroupSortable(fields[i], $(formId + ' #'+fields[i][0]+"_div_inner")); - }catch(e){} + }catch(e){} - }else if(fields[i][1].type == 'signature'){ + }else if(fields[i][1].type == 'signature'){ if(object[fields[i][0]] != '' || object[fields[i][0]] != undefined || object[fields[i][0]] != null){ $(formId + ' #'+fields[i][0]).data('signaturePad').fromDataURL(object[fields[i][0]]); } - }else if(fields[i][1].type == 'simplemde'){ - $(formId + ' #'+fields[i][0]).data('simplemde').value(object[fields[i][0]]); - }else{ - $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); - } + }else if(fields[i][1].type == 'simplemde'){ + $(formId + ' #'+fields[i][0]).data('simplemde').value(object[fields[i][0]]); + }else{ + $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); + } - } + } }); /** @@ -2074,132 +2075,135 @@ IceHRMBase.method('fillForm', function(object, formId, fields) { */ IceHRMBase.method('cancel', function() { - $("#"+this.getTableName()+'Form').hide(); - $("#"+this.getTableName()).show(); + $("#"+this.getTableName()+'Form').hide(); + $("#"+this.getTableName()).show(); }); IceHRMBase.method('renderFormField', function(field) { - var userId = 0; - if(this.fieldTemplates[field[1].type] == undefined || this.fieldTemplates[field[1].type] == null){ - return ""; - } - var t = this.fieldTemplates[field[1].type]; - field[1].label = this.gt(field[1].label); - if(field[1].validation != "none" && field[1].validation != "emailOrEmpty" && field[1].validation != "numberOrEmpty" && field[1].type != "placeholder" && field[1].label.indexOf('*') < 0){ - var tempSelectBoxes = ['select','select2']; - if(tempSelectBoxes.indexOf(field[1].type) >= 0 && field[1]['allow-null'] == true){ + var userId = 0; + if(this.fieldTemplates[field[1].type] == undefined || this.fieldTemplates[field[1].type] == null){ + return ""; + } + var t = this.fieldTemplates[field[1].type]; + field[1].label = this.gt(field[1].label); + if(field[1].validation != "none" && field[1].validation != "emailOrEmpty" && field[1].validation != "numberOrEmpty" && field[1].type != "placeholder" && field[1].label.indexOf('*') < 0){ + var tempSelectBoxes = ['select','select2']; + if(tempSelectBoxes.indexOf(field[1].type) >= 0 && field[1]['allow-null'] == true){ - }else{ - field[1].label = field[1].label + '*'; - } + }else{ + field[1].label = field[1].label + '*'; + } - } - if(field[1].type == 'text' || field[1].type == 'textarea' || field[1].type == 'hidden' || field[1].type == 'label' || field[1].type == 'placeholder'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); + } + if(field[1].type == 'text' || field[1].type == 'textarea' || field[1].type == 'hidden' || field[1].type == 'label' || field[1].type == 'placeholder'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); - }else if(field[1].type == 'select' || field[1].type == 'select2' || field[1].type == 'select2multi'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - if(field[1]['source'] != undefined && field[1]['source'] != null ){ - t = t.replace('_options_',this.renderFormSelectOptions(field[1].source, field)); - }else if(field[1]['remote-source'] != undefined && field[1]['remote-source'] != null ){ - var key = field[1]['remote-source'][0]+"_"+field[1]['remote-source'][1]+"_"+field[1]['remote-source'][2]; - t = t.replace('_options_',this.renderFormSelectOptionsRemote(this.fieldMasterData[key],field)); - } + }else if(field[1].type == 'select' || field[1].type == 'select2' || field[1].type == 'select2multi'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); + if(field[1]['source'] != undefined && field[1]['source'] != null ){ + t = t.replace('_options_',this.renderFormSelectOptions(field[1].source, field)); + }else if(field[1]['remote-source'] != undefined && field[1]['remote-source'] != null ){ + var key = field[1]['remote-source'][0]+"_"+field[1]['remote-source'][1]+"_"+field[1]['remote-source'][2]; + t = t.replace('_options_',this.renderFormSelectOptionsRemote(this.fieldMasterData[key],field)); + } - }else if(field[1].type == 'colorpick'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); + }else if(field[1].type == 'colorpick'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); - }else if(field[1].type == 'date'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); + }else if(field[1].type == 'date'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); - }else if(field[1].type == 'datetime'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); + }else if(field[1].type == 'datetime'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); - }else if(field[1].type == 'time'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); + }else if(field[1].type == 'time'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); - }else if(field[1].type == 'fileupload'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - var ce = this.getCurrentProfile(); - if(ce != null && ce != undefined){ - userId = ce.id; - }else{ - userId = this.getUser().id * -1; - } - t = t.replace(/_userId_/g,userId); - t = t.replace(/_group_/g,this.tab); + }else if(field[1].type == 'fileupload'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); + var ce = this.getCurrentProfile(); + if(ce != null && ce != undefined){ + userId = ce.id; + }else{ + userId = this.getUser().id * -1; + } + t = t.replace(/_userId_/g,userId); + t = t.replace(/_group_/g,this.tab); - if(field[1].filetypes != undefined && field[1].filetypes != null){ - t = t.replace(/_filetypes_/g,field[1].filetypes); - }else{ - t = t.replace(/_filetypes_/g,'all'); - } + if(field[1].filetypes != undefined && field[1].filetypes != null){ + t = t.replace(/_filetypes_/g,field[1].filetypes); + }else{ + t = t.replace(/_filetypes_/g,'all'); + } - /* - if(object != null && object != undefined && object[field[0]] != null && object[field[0]] != undefined && object[field[0]] != ""){ - t = t.replace(/_id___rand_/g,field[0]); - } - */ - t = t.replace(/_rand_/g,this.generateRandom(14)); + t = t.replace(/_rand_/g,this.generateRandom(14)); - }else if(field[1].type == 'datagroup'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); + }else if(field[1].type == 'datagroup'){ + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); - }else if(field[1].type == 'signature'){ + }else if(field[1].type == 'signature'){ t = t.replace(/_id_/g,field[0]); t = t.replace(/_label_/g,field[1].label); }else if(field[1].type == 'tinymce' || field[1].type == 'simplemde'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - } + t = t.replace(/_id_/g,field[0]); + t = t.replace(/_label_/g,field[1].label); + } - if(field[1].validation != undefined && field[1].validation != null && field[1].validation != ""){ - t = t.replace(/_validation_/g,'validation="'+field[1].validation+'"'); - }else{ - t = t.replace(/_validation_/g,''); - } + if(field[1].validation != undefined && field[1].validation != null && field[1].validation != "") { + t = t.replace(/_validation_/g,'validation="'+field[1].validation+'"'); + }else{ + t = t.replace(/_validation_/g,''); + } - if(field[1].help != undefined || field[1].help != null){ - t = t.replace(/_helpline_/g,field[1].help); - }else{ - t = t.replace(/_helpline_/g,''); - } + if(field[1].help !== undefined && field[1].help !== null){ + t = t.replace(/_helpline_/g,field[1].help); + t = t.replace(/_hidden_class_help_/g,''); + }else{ + t = t.replace(/_helpline_/g,''); + t = t.replace(/_hidden_class_help_/g,'hide'); + } - return t; + if (field[1].placeholder !== undefined && field[1].placeholder !== null) { + t = t.replace(/_placeholder_/g,'placeholder="'+field[1].placeholder+'"'); + }else{ + t = t.replace(/_placeholder_/g,''); + } + + return t; }); IceHRMBase.method('renderFormSelectOptions', function(options, field) { - var html = ""; + var html = ""; - if(field != null && field != undefined){ - if(field[1]['allow-null'] == true){ - if(field[1]['null-label'] != undefined && field[1]['null-label'] != null){ - html += ''; - }else{ - html += ''; - } + if(field != null && field != undefined){ + if(field[1]['allow-null'] == true){ + if(field[1]['null-label'] != undefined && field[1]['null-label'] != null){ + html += ''; + }else{ + html += ''; + } - } - } + } + } - //Sort options + //Sort options - var tuples = []; + var tuples = []; - for (var key in options) { - tuples.push(options[key]); - } + for (var key in options) { + tuples.push(options[key]); + } if(field[1]['sort'] != 'none'){ tuples.sort(function(a, b) { a = a[1]; @@ -2210,37 +2214,37 @@ IceHRMBase.method('renderFormSelectOptions', function(options, field) { } - for (var i = 0; i < tuples.length; i++) { - var prop = tuples[i][0]; - var value = tuples[i][1]; - var t = ''; - t = t.replace('_id_', prop); - t = t.replace('_val_', value); - html += t; + for (var i = 0; i < tuples.length; i++) { + var prop = tuples[i][0]; + var value = tuples[i][1]; + var t = ''; + t = t.replace('_id_', prop); + t = t.replace('_val_', value); + html += t; - } - return html; + } + return html; }); IceHRMBase.method('renderFormSelectOptionsRemote', function(options,field) { - var html = ""; - if(field[1]['allow-null'] == true){ - if(field[1]['null-label'] != undefined && field[1]['null-label'] != null){ - html += ''; - }else{ - html += ''; - } + var html = ""; + if(field[1]['allow-null'] == true){ + if(field[1]['null-label'] != undefined && field[1]['null-label'] != null){ + html += ''; + }else{ + html += ''; + } - } + } - //Sort options + //Sort options - var tuples = []; + var tuples = []; - for (var key in options) { - tuples.push([key, options[key]]); - } + for (var key in options) { + tuples.push([key, options[key]]); + } if(field[1]['sort'] != 'none') { tuples.sort(function (a, b) { a = a[1]; @@ -2250,52 +2254,52 @@ IceHRMBase.method('renderFormSelectOptionsRemote', function(options,field) { }); } - for (var i = 0; i < tuples.length; i++) { - var prop = tuples[i][0]; - var value = tuples[i][1]; + for (var i = 0; i < tuples.length; i++) { + var prop = tuples[i][0]; + var value = tuples[i][1]; - var t = ''; - t = t.replace('_id_', prop); - t = t.replace('_val_', value); - html += t; - } + var t = ''; + t = t.replace('_id_', prop); + t = t.replace('_val_', value); + html += t; + } - return html; + return html; }); IceHRMBase.method('setTemplates', function(templates) { - this.templates = templates; + this.templates = templates; }); IceHRMBase.method('setCustomTemplates', function(templates) { - this.customTemplates = templates; + this.customTemplates = templates; }); IceHRMBase.method('setEmailTemplates', function(templates) { - this.emailTemplates = templates; + this.emailTemplates = templates; }); IceHRMBase.method('getCustomTemplate', function(file) { - return this.customTemplates[file]; + return this.customTemplates[file]; }); IceHRMBase.method('setFieldTemplates', function(templates) { - this.fieldTemplates = templates; + this.fieldTemplates = templates; }); IceHRMBase.method('getMetaFieldForRendering', function(fieldName) { - return ""; + return ""; }); IceHRMBase.method('clearDeleteParams', function() { - this.deleteParams = {}; + this.deleteParams = {}; }); IceHRMBase.method('getShowAddNew', function() { - return this.showAddNew; + return this.showAddNew; }); /** @@ -2304,7 +2308,7 @@ IceHRMBase.method('getShowAddNew', function() { */ IceHRMBase.method('getAddNewLabel', function() { - return "Add New"; + return "Add New"; }); /** @@ -2314,7 +2318,7 @@ IceHRMBase.method('getAddNewLabel', function() { */ IceHRMBase.method('setShowAddNew', function(showAddNew) { - this.showAddNew = showAddNew; + this.showAddNew = showAddNew; }); /** @@ -2323,7 +2327,7 @@ IceHRMBase.method('setShowAddNew', function(showAddNew) { * @param val {Boolean} value */ IceHRMBase.method('setShowDelete', function(val) { - this.showDelete = val; + this.showDelete = val; }); @@ -2334,7 +2338,7 @@ IceHRMBase.method('setShowDelete', function(val) { */ IceHRMBase.method('setShowEdit', function(val) { - this.showEdit = val; + this.showEdit = val; }); /** @@ -2345,7 +2349,7 @@ IceHRMBase.method('setShowEdit', function(val) { IceHRMBase.method('setShowSave', function(val) { - this.showSave = val; + this.showSave = val; }); @@ -2356,7 +2360,7 @@ IceHRMBase.method('setShowSave', function(val) { */ IceHRMBase.method('setShowCancel', function(val) { - this.showCancel = val; + this.showCancel = val; }); /** @@ -2367,11 +2371,11 @@ IceHRMBase.method('setShowCancel', function(val) { IceHRMBase.method('getCustomTableParams', function() { - return {}; + return {}; }); IceHRMBase.method('getActionButtons', function(obj) { - return modJs.getActionButtonsHtml(obj.aData[0],obj.aData); + return modJs.getActionButtonsHtml(obj.aData[0],obj.aData); }); @@ -2384,32 +2388,32 @@ IceHRMBase.method('getActionButtons', function(obj) { */ IceHRMBase.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - var deleteButton = ''; - var cloneButton = ''; - var html = '
    _edit__delete__clone_
    '; + var editButton = ''; + var deleteButton = ''; + var cloneButton = ''; + var html = '
    _edit__delete__clone_
    '; - if(this.showAddNew){ - html = html.replace('_clone_',cloneButton); - }else{ - html = html.replace('_clone_',''); - } + if(this.showAddNew){ + html = html.replace('_clone_',cloneButton); + }else{ + html = html.replace('_clone_',''); + } - if(this.showDelete){ - html = html.replace('_delete_',deleteButton); - }else{ - html = html.replace('_delete_',''); - } + if(this.showDelete){ + html = html.replace('_delete_',deleteButton); + }else{ + html = html.replace('_delete_',''); + } - if(this.showEdit){ - html = html.replace('_edit_',editButton); - }else{ - html = html.replace('_edit_',''); - } + if(this.showEdit){ + html = html.replace('_edit_',editButton); + }else{ + html = html.replace('_edit_',''); + } - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; + html = html.replace(/_id_/g,id); + html = html.replace(/_BASE_/g,this.baseUrl); + return html; }); @@ -2421,56 +2425,56 @@ IceHRMBase.method('getActionButtonsHtml', function(id,data) { */ IceHRMBase.method('generateRandom', function(length) { - var d = new Date(); - var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - var result = ''; - for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; - return result+d.getTime(); + var d = new Date(); + var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + var result = ''; + for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; + return result+d.getTime(); }); IceHRMBase.method('checkFileType', function (elementName, fileTypes) { - var fileElement = document.getElementById(elementName); - var fileExtension = ""; - if (fileElement.value.lastIndexOf(".") > 0) { - fileExtension = fileElement.value.substring(fileElement.value.lastIndexOf(".") + 1, fileElement.value.length); - } + var fileElement = document.getElementById(elementName); + var fileExtension = ""; + if (fileElement.value.lastIndexOf(".") > 0) { + fileExtension = fileElement.value.substring(fileElement.value.lastIndexOf(".") + 1, fileElement.value.length); + } - fileExtension = fileExtension.toLowerCase(); + fileExtension = fileExtension.toLowerCase(); - var allowed = fileTypes.split(","); + var allowed = fileTypes.split(","); - if (allowed.indexOf(fileExtension) < 0) { - fileElement.value = ""; - this.showMessage("File Type Error",'Selected file type is not supported'); - this.clearFileElement(elementName); - return false; - } + if (allowed.indexOf(fileExtension) < 0) { + fileElement.value = ""; + this.showMessage("File Type Error",'Selected file type is not supported'); + this.clearFileElement(elementName); + return false; + } - return true; + return true; }); IceHRMBase.method('clearFileElement', function (elementName) { - var control = $("#"+elementName); - control.replaceWith( control = control.val('').clone( true ) ); + var control = $("#"+elementName); + control.replaceWith( control = control.val('').clone( true ) ); }); IceHRMBase.method('fixJSON', function (json) { - if(this.noJSONRequests == "1"){ - json = window.btoa(json); - } - return json; + if(this.noJSONRequests == "1"){ + json = window.btoa(json); + } + return json; }); IceHRMBase.method('getClientDate', function (date) { - var offset = this.getClientGMTOffset(); + var offset = this.getClientGMTOffset(); var tzDate = date.addMinutes(offset*60); return tzDate; @@ -2478,13 +2482,13 @@ IceHRMBase.method('getClientDate', function (date) { IceHRMBase.method('getClientGMTOffset', function () { - var rightNow = new Date(); - var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); - var temp = jan1.toGMTString(); - var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); - var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); + var rightNow = new Date(); + var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); + var temp = jan1.toGMTString(); + var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); + var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); - return std_time_offset; + return std_time_offset; }); @@ -2496,16 +2500,16 @@ IceHRMBase.method('getClientGMTOffset', function () { IceHRMBase.method('getHelpLink', function () { - return null; + return null; }); IceHRMBase.method('showLoader', function () { - $('#iceloader').show(); + $('#iceloader').show(); }); IceHRMBase.method('hideLoader', function () { - $('#iceloader').hide(); + $('#iceloader').hide(); }); IceHRMBase.method('generateOptions', function (data) { diff --git a/api/FormValidation.js b/api/FormValidation.js index 32903052..152a5d9b 100644 --- a/api/FormValidation.js +++ b/api/FormValidation.js @@ -16,269 +16,265 @@ along with Ice Framework. If not, see . ------------------------------------------------------------------ -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] +Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) */ ValidationRules = { - float: function (str) { - var floatstr = /^[-+]?[0-9]+(\.[0-9]+)?$/; - if (str != null && str.match(floatstr)) { - return true; - } else { - return false; - } - }, + float: function (str) { + var floatstr = /^[-+]?[0-9]+(\.[0-9]+)?$/; + if (str != null && str.match(floatstr)) { + return true; + } else { + return false; + } + }, - number: function (str) { - var numstr = /^[0-9]+$/; - if (str != null && str.match(numstr)) { - return true; - } else { - return false; - } - }, + number: function (str) { + var numstr = /^[0-9]+$/; + if (str != null && str.match(numstr)) { + return true; + } else { + return false; + } + }, - numberOrEmpty: function (str) { - if(str == ""){ - return true; - } - var numstr = /^[0-9]+$/; - if (str != null && str.match(numstr)) { - return true; - } else { - return false; - } - }, + numberOrEmpty: function (str) { + if(str == ""){ + return true; + } + var numstr = /^[0-9]+$/; + if (str != null && str.match(numstr)) { + return true; + } else { + return false; + } + }, - email: function (str) { - var emailPattern = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; - return str != null && emailPattern.test(str); - }, + email: function (str) { + var emailPattern = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; + return str != null && emailPattern.test(str); + }, - emailOrEmpty: function (str) { - if(str == ""){ - return true; - } - var emailPattern = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; - return str != null && emailPattern.test(str); - }, + emailOrEmpty: function (str) { + if(str == ""){ + return true; + } + var emailPattern = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; + return str != null && emailPattern.test(str); + }, - username: function (str) { - var username = /^[a-zA-Z0-9\.-]+$/; - return str != null && username.test(str); - }, + username: function (str) { + var username = /^[a-zA-Z0-9\.-]+$/; + return str != null && username.test(str); + }, - input: function (str) { - if (str != null && str.length > 0) { - return true; - } else { - return false; - } - } + input: function (str) { + if (str != null && str.length > 0) { + return true; + } else { + return false; + } + } }; function FormValidation(formId,validateAll,options) { - this.tempOptions = {}; - this.formId = formId; - this.formError = false; - this.formObject = null; - this.errorMessages = ""; - this.popupDialog = null; - this.validateAll = validateAll; - this.errorMap = new Array(); - - this.settings = {"thirdPartyPopup":null,"LabelErrorClass":false, "ShowPopup":true}; - - this.settings = jQuery.extend(this.settings,options); - - this.inputTypes = new Array( "text", "radio", "checkbox", "file", "password", "select-one","select-multi", "textarea","fileupload" ,"signature"); + this.tempOptions = {}; + this.formId = formId; + this.formError = false; + this.formObject = null; + this.errorMessages = ""; + this.popupDialog = null; + this.validateAll = validateAll; + this.errorMap = new Array(); - this.validator = ValidationRules; + this.settings = {"thirdPartyPopup":null,"LabelErrorClass":false, "ShowPopup":true}; + + this.settings = jQuery.extend(this.settings,options); + + this.inputTypes = new Array( "text", "radio", "checkbox", "file", "password", "select-one","select-multi", "textarea","fileupload" ,"signature"); + + this.validator = ValidationRules; } FormValidation.method('clearError' , function(formInput, overrideMessage) { - var id = formInput.attr("id"); - $('#'+ this.formId +' #field_'+id).removeClass('error'); - $('#'+ this.formId +' #help_'+id).html(''); + var id = formInput.attr("id"); + $('#'+ this.formId +' #field_'+id).removeClass('error'); + $('#'+ this.formId +' #help_'+id).html(''); }); - -FormValidation.method('addError' , function(formInput, overrideMessage) { - this.formError = true; - if(formInput.attr("message") != null) { - this.errorMessages += (formInput.attr("message") + "\n"); - this.errorMap[formInput.attr("name")] = formInput.attr("message"); - }else{ - this.errorMap[formInput.attr("name")] = ""; - } - var id = formInput.attr("id"); - var validation = formInput.attr("validation"); - var message = formInput.attr("validation"); - $('#'+ this.formId +' #field_'+id).addClass('error'); - if(message == undefined || message == null || message == ""){ - $('#'+ this.formId +' #help_'+id).html(message); - }else{ - if(validation == undefined || validation == null || validation == ""){ - $('#'+ this.formId +' #help_'+id).html("Required"); - }else{ - if(validation == "float" || validation == "number"){ - $('#'+ this.formId +' #help_'+id).html("Number required"); - }else if(validation == "email"){ - $('#'+ this.formId +' #help_'+id).html("Email required"); - }else{ - $('#'+ this.formId +' #help_'+id).html("Required"); - } - } - } - - +FormValidation.method('addError' , function(formInput, overrideMessage) { + this.formError = true; + if(formInput.attr("message") != null) { + this.errorMessages += (formInput.attr("message") + "\n"); + this.errorMap[formInput.attr("name")] = formInput.attr("message"); + }else{ + this.errorMap[formInput.attr("name")] = ""; + } + + var id = formInput.attr("id"); + var validation = formInput.attr("validation"); + var message = formInput.attr("validation"); + $('#'+ this.formId +' #field_'+id).addClass('error'); + if(message == undefined || message == null || message == ""){ + $('#'+ this.formId +' #help_err_'+id).html(message); + }else{ + if(validation == undefined || validation == null || validation == ""){ + $('#'+ this.formId +' #help_err_'+id).html("Required"); + }else{ + if(validation == "float" || validation == "number"){ + $('#'+ this.formId +' #help_err_'+id).html("Number required"); + }else if(validation == "email"){ + $('#'+ this.formId +' #help_err_'+id).html("Email required"); + }else{ + $('#'+ this.formId +' #help_err_'+id).html("Required"); + } + } + } + + }); - + FormValidation.method('showErrors' , function() { - if(this.formError) { - if(this.settings['thirdPartyPopup'] != undefined && this.settings['thirdPartyPopup'] != null){ - this.settings['thirdPartyPopup'].alert(); - }else{ - if(this.settings['ShowPopup'] == true){ - if(this.tempOptions['popupTop'] != undefined && this.tempOptions['popupTop'] != null){ - this.alert("Errors Found",this.errorMessages,this.tempOptions['popupTop']); - }else{ - this.alert("Errors Found",this.errorMessages,-1); - } - - } - } + if(this.formError) { + if(this.settings['thirdPartyPopup'] != undefined && this.settings['thirdPartyPopup'] != null){ + this.settings['thirdPartyPopup'].alert(); + }else{ + if(this.settings['ShowPopup'] == true){ + if(this.tempOptions['popupTop'] != undefined && this.tempOptions['popupTop'] != null){ + this.alert("Errors Found",this.errorMessages,this.tempOptions['popupTop']); + }else{ + this.alert("Errors Found",this.errorMessages,-1); + } + + } + } } }); - - + + FormValidation.method('checkValues' , function(options) { - this.tempOptions = options; - var that = this; - this.formError = false; - this.errorMessages = ""; - this.formObject = new Object(); - var validate = function (inputObject) { - if(that.settings['LabelErrorClass'] != false){ - $("label[for='" + name + "']").removeClass(that.settings['LabelErrorClass']); - } - var id = inputObject.attr("id"); - var name = inputObject.attr("name"); - var type = inputObject.attr("type"); - - if(inputObject.hasClass('select2-focusser') || inputObject.hasClass('select2-input')){ - return true; - } - - if(jQuery.inArray(type, that.inputTypes ) >= 0) { - if(inputObject.hasClass('uploadInput')){ - inputValue = inputObject.attr("val"); - //}else if(inputObject.hasClass('datetimeInput')){ - //inputValue = inputObject.getDate()+":00"; - }else{ - //inputValue = (type == "radio" || type == "checkbox")?$("input[name='" + name + "']:checked").val():inputObject.val(); - - inputValue = null; - if(type == "radio" || type == "checkbox"){ - inputValue = $("input[name='" + name + "']:checked").val(); - }else if(inputObject.hasClass('select2Field')){ - if($('#'+id).select2('data') != null && $('#'+id).select2('data') != undefined){ - inputValue = $('#'+id).select2('data').id; - }else{ - inputValue = ""; - } - - }else if(inputObject.hasClass('select2Multi')){ - if($('#'+id).select2('data') != null && $('#'+id).select2('data') != undefined){ - inputValueObjects = $('#'+id).select2('data'); - inputValue = []; - for(var i=0;i= 0) { + if(inputObject.hasClass('uploadInput')){ + inputValue = inputObject.attr("val"); + //}else if(inputObject.hasClass('datetimeInput')){ + //inputValue = inputObject.getDate()+":00"; + }else{ + //inputValue = (type == "radio" || type == "checkbox")?$("input[name='" + name + "']:checked").val():inputObject.val(); + + inputValue = null; + if(type == "radio" || type == "checkbox"){ + inputValue = $("input[name='" + name + "']:checked").val(); + }else if(inputObject.hasClass('select2Field')){ + if($('#'+id).select2('data') != null && $('#'+id).select2('data') != undefined){ + inputValue = $('#'+id).select2('data').id; + }else{ + inputValue = ""; + } + + }else if(inputObject.hasClass('select2Multi')){ + if($('#'+id).select2('data') != null && $('#'+id).select2('data') != undefined){ + inputValueObjects = $('#'+id).select2('data'); + inputValue = []; + for(var i=0;iLoad('name = ?', array('si')); + $supportedLanguage->Delete(); + + $supportedLanguage = new SupportedLanguage(); + $supportedLanguage->Load('name = ?', array('hi')); + $supportedLanguage->Delete(); + + return true; + } + + public function down(){ + $supportedLanguage = new SupportedLanguage(); + $supportedLanguage->name = 'si'; + $supportedLanguage->description = 'Sinhala'; + $supportedLanguage->Save(); + + $supportedLanguage = new SupportedLanguage(); + $supportedLanguage->name = 'hi'; + $supportedLanguage->description = 'Hindi'; + $supportedLanguage->Save(); + return true; + } + +} + diff --git a/robo/RoboFile.php b/robo/RoboFile.php index 7b28e671..4228e43b 100644 --- a/robo/RoboFile.php +++ b/robo/RoboFile.php @@ -22,6 +22,59 @@ class RoboFile extends \Robo\Tasks $this->say("Hello, " . implode(', ', $world)); } + function languageList($client) { + $this->includeCientConfig($client); + $this->say("Supported Languages for ". $client); + $language = new \Metadata\Common\Model\SupportedLanguage(); + $langs = $language->Find('1 = 1'); + + $this->say(print_r(array_column($langs, 'name'), true)); + } + + function languageExport($client) { + $this->includeCientConfig($client); + $language = new \Metadata\Common\Model\SupportedLanguage(); + $languages = $language->Find('1 = 1 order by id'); + $data = []; + $data[0] = []; + $data[0][] = 'Key'; + foreach ($languages as $lang) { + $data[0][] = $lang->name; + $trans = \Classes\LanguageManager::getTranslations($lang->name); + $trans = json_decode($trans, true)['messages']['']; + $count = 1; + foreach ($trans as $enVal => $langVal) { + if (!isset($data[$count])) { + $data[$count] = []; + $data[$count][] = $enVal; + } + $data[$count][] = $langVal[0]; + $count += 1; + } + } + $fp = fopen(CLIENT_BASE_PATH.'data/translations.csv', 'w'); + foreach ($data as $fields) { + fprintf($fp, chr(0xEF).chr(0xBB).chr(0xBF)); + fputcsv($fp, $fields); + } + fclose($fp); + $this->say('File saved'); + } + + function languageImport($client, $file) { + $this->includeCientConfig($client); + + $language = new \Metadata\Common\Model\SupportedLanguage(); + $languages = $language->Find('1 = 1 order by id'); + foreach ($languages as $language) { + $str = $this->getUpdatedTranslationString($language->name, $file); + file_put_contents( + __DIR__.'/../lang/'.$language->name.'.po', + $str); + $this->say('Updated :'.realpath(__DIR__.'/../lang/'.$language->name.'.po')); + } + } + function migrate($client, $action){ $this->includeCientConfig($client); $this->say("DB Migrating " . $action . " for ". $client); @@ -50,4 +103,44 @@ class RoboFile extends \Robo\Tasks } $this->say("DB Migration Completed !!!"); } + + /** + * @param $lang + * @param $file + * @return mixed + */ + protected function getUpdatedTranslationString($lang, $file) + { + $handle = fopen(CLIENT_BASE_PATH . 'data/' . $file, "r"); + $langColumn = null; + /* @var \Gettext\Translations $trans */ + $trans = \Classes\LanguageManager::getTranslationsObject($lang); + while (($data = fgetcsv($handle)) !== FALSE) { + if ($langColumn === null) { + $currentColumn = 0; + foreach ($data as $language) { + if ($language === $lang) { + $langColumn = $currentColumn; + break; + } + $currentColumn++; + } + + if ($langColumn === null) { + $this->say('Invalid Language'); + exit(); + } + } else { + /* @var \Gettext\Translation $tran */ + $tran = $trans->find('', $data[0]); + if ($tran !== false) { + $tran->setTranslation($data[$langColumn]); + } else { + $trans->insert($data[0], $data[$langColumn]); + } + } + } + + return $trans->toPoString(); + } } diff --git a/src/Classes/LanguageManager.php b/src/Classes/LanguageManager.php index c7bc4364..6ffbfd01 100644 --- a/src/Classes/LanguageManager.php +++ b/src/Classes/LanguageManager.php @@ -9,40 +9,45 @@ use Utils\LogManager; class LanguageManager { - private static $me = null; + private static $me = []; /* @var \Gettext\Translator $translator */ private $translator = null; + /* @var \Gettext\Translations $translations */ private $translations = null; private function __construct() { } - private static function getInstance() + private static function getInstance($lang = null) { - if (empty(self::$me)) { - self::$me = new LanguageManager(); - self::$me->loadLanguage(); + if ($lang === null) { + $lang = self::getCurrentLang(); + } + if (empty(self::$me[$lang])) { + self::$me[$lang] = new LanguageManager(); + self::$me[$lang]->initialize($lang); } - return self::$me; + return self::$me[$lang]; } - private function loadLanguage() + private function initialize($lang) + { + $this->loadLanguage($lang); + } + + public function loadLanguage($lang) { - $lang = $this->getCurrentLang(); $this->translations = Translations::fromPoFile(APP_BASE_PATH.'lang/'.$lang.'.po'); - if (file_exists(APP_BASE_PATH.'lang/'.$lang.'-ext.po')) { - $this->translations->addFromPoFile(APP_BASE_PATH.'lang/'.$lang.'-ext.po'); - } $t = new Translator(); $t->loadTranslations($this->translations); $t->register(); $this->translator = $t; } - private function getCurrentLang() + private static function getCurrentLang() { $user = BaseService::getInstance()->getCurrentUser(); if (empty($user) || empty($user->lang) || $user->lang == "NULL") { @@ -56,16 +61,21 @@ class LanguageManager if (empty($lang) || !file_exists(APP_BASE_PATH.'lang/'.$lang.'.po')) { $lang = 'en'; } - LogManager::getInstance()->info("Current Language:".$lang); return $lang; } - public static function getTranslations() + public static function getTranslations($lang = null) { - $me = self::getInstance(); + $me = self::getInstance($lang); return Json::toString($me->translations); } + public static function getTranslationsObject($lang = null) + { + $me = self::getInstance($lang); + return $me->translations; + } + public static function tran($text) { $me = self::getInstance(); diff --git a/templates/fields/colorpick.html b/templates/fields/colorpick.html index 797f764f..013dca07 100644 --- a/templates/fields/colorpick.html +++ b/templates/fields/colorpick.html @@ -7,6 +7,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/datagroup.html b/templates/fields/datagroup.html index 853e30fc..4aa8566d 100644 --- a/templates/fields/datagroup.html +++ b/templates/fields/datagroup.html @@ -6,9 +6,11 @@
    - +
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/date.html b/templates/fields/date.html index de857236..18a086e0 100644 --- a/templates/fields/date.html +++ b/templates/fields/date.html @@ -4,10 +4,12 @@
    - +
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/datetime.html b/templates/fields/datetime.html index 05346696..e7d5efeb 100644 --- a/templates/fields/datetime.html +++ b/templates/fields/datetime.html @@ -6,10 +6,12 @@ - +
    - _helpline_ +
    +
    diff --git a/templates/fields/fileupload.html b/templates/fields/fileupload.html index c9d92ff8..2c7e86f0 100644 --- a/templates/fields/fileupload.html +++ b/templates/fields/fileupload.html @@ -7,6 +7,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/label.html b/templates/fields/label.html index 00bfc1f9..14d9c8c1 100644 --- a/templates/fields/label.html +++ b/templates/fields/label.html @@ -4,6 +4,8 @@
    - +
    +
    - \ No newline at end of file + diff --git a/templates/fields/placeholder.html b/templates/fields/placeholder.html index a090f985..7c37c5ae 100644 --- a/templates/fields/placeholder.html +++ b/templates/fields/placeholder.html @@ -4,6 +4,8 @@
    - +
    +
    - \ No newline at end of file + diff --git a/templates/fields/select.html b/templates/fields/select.html index 97eb914b..1ce7e954 100644 --- a/templates/fields/select.html +++ b/templates/fields/select.html @@ -6,6 +6,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/select2.html b/templates/fields/select2.html index 1dff72b6..d101dfb9 100644 --- a/templates/fields/select2.html +++ b/templates/fields/select2.html @@ -6,6 +6,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/select2multi.html b/templates/fields/select2multi.html index ca6e0d03..9aa65983 100644 --- a/templates/fields/select2multi.html +++ b/templates/fields/select2multi.html @@ -6,6 +6,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/signature.html b/templates/fields/signature.html index 5f7e71c6..bb7c161b 100644 --- a/templates/fields/signature.html +++ b/templates/fields/signature.html @@ -4,6 +4,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/simplemde.html b/templates/fields/simplemde.html index 9123beab..a62a24f3 100644 --- a/templates/fields/simplemde.html +++ b/templates/fields/simplemde.html @@ -4,6 +4,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/fields/text.html b/templates/fields/text.html index 779a43ce..6f18adec 100644 --- a/templates/fields/text.html +++ b/templates/fields/text.html @@ -1,9 +1,11 @@
    - +
    - _helpline_ +
    +
    -
    \ No newline at end of file + diff --git a/templates/fields/textarea.html b/templates/fields/textarea.html index a002f268..31eebd11 100644 --- a/templates/fields/textarea.html +++ b/templates/fields/textarea.html @@ -1,9 +1,11 @@
    - +
    - _helpline_ +
    +
    -
    \ No newline at end of file + diff --git a/templates/fields/time.html b/templates/fields/time.html index d11811be..534d9b2f 100644 --- a/templates/fields/time.html +++ b/templates/fields/time.html @@ -6,10 +6,12 @@ - +
    - _helpline_ +
    +
    diff --git a/templates/fields/tinymce.html b/templates/fields/tinymce.html index 08e3978f..1feaefaa 100644 --- a/templates/fields/tinymce.html +++ b/templates/fields/tinymce.html @@ -4,6 +4,8 @@
    - _helpline_ +
    +
    - \ No newline at end of file + diff --git a/templates/form_template.html b/templates/form_template.html index 4aac3411..ea1eda0f 100644 --- a/templates/form_template.html +++ b/templates/form_template.html @@ -2,8 +2,8 @@
    -
    - +
    +
    _fields_ diff --git a/test/TestTemplate.php b/test/TestTemplate.php index 615b14b1..9e4800be 100644 --- a/test/TestTemplate.php +++ b/test/TestTemplate.php @@ -1,8 +1,12 @@ assertEquals('cat', LanguageManager::tran('cat')); @@ -20,4 +21,23 @@ class LanguageManagerUnit extends \TestTemplate $this->assertEquals('User Logged In now', LanguageManager::translateTnrText('User Logged In now')); fwrite(STDOUT, __METHOD__ . " End\n"); } + + public function testGetTranslations() { + + $enCount = $this->getTranslationCount('en'); + + $this->assertEquals($enCount, $this->getTranslationCount('de')); + $this->assertEquals($enCount, $this->getTranslationCount('es')); + $this->assertEquals($enCount, $this->getTranslationCount('fr')); + $this->assertEquals($enCount, $this->getTranslationCount('hi')); + $this->assertEquals($enCount, $this->getTranslationCount('it')); + $this->assertEquals($enCount, $this->getTranslationCount('ja')); + $this->assertEquals($enCount, $this->getTranslationCount('pl')); + $this->assertEquals($enCount, $this->getTranslationCount('zh')); + } + + private function getTranslationCount($lang) { + $trans = json_decode(LanguageManager::getTranslations($lang), true); + $count = count(array_keys($trans['messages'][''])); + } }