From 1e9e6f31a2e301a7dd854822bdd09e31dca8084a Mon Sep 17 00:00:00 2001 From: Thilina Hasantha Date: Thu, 4 Aug 2016 17:09:17 +0530 Subject: [PATCH] Fix related to employee custom fields --- ext/admin/employees/lib.js | 37 +++++++++++++++++++ .../employees/customTemplates/myDetails.html | 9 +---- ext/modules/employees/lib.js | 22 ++++++++++- readme.md | 4 +- 4 files changed, 60 insertions(+), 12 deletions(-) diff --git a/ext/admin/employees/lib.js b/ext/admin/employees/lib.js index 3a266173..1f7e0c77 100644 --- a/ext/admin/employees/lib.js +++ b/ext/admin/employees/lib.js @@ -447,6 +447,43 @@ EmployeeAdapter.method('renderEmployee', function(data) { $("#"+this.getTableName()+" #profile_image_"+data.id).attr('src',data.image); + + var sectionTemplate = '

#_section.name_#

'; + var sectionId = ''; + var sectionHtml = ''; + //Add custom fields + if(data.customFields != undefined && data.customFields != null && Object.keys(data.customFields).length > 0) { + + + var ct = '
'; + var customFieldHtml; + for (index in data.customFields) { + + if(!data.customFields[index][1]){ + data.customFields[index][1] = 'Other Details'; + } + + sectionId = data.customFields[index][1].toLocaleLowerCase(); + sectionId = sectionId.replace(' ','_'); + + if($("#cont_"+sectionId).length <= 0){ + //Add section + sectionHtml = sectionTemplate; + sectionHtml = sectionHtml.replace('#_section_#', sectionId); + sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); + $("#customFieldsCont").append($(sectionHtml)); + } + + customFieldHtml = ct; + customFieldHtml = customFieldHtml.replace('#_label_#', index); + customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); + $("#cont_"+sectionId).append($(customFieldHtml)); + } + }else{ + $("#customFieldsCont").remove(); + } + + this.cancel(); if(!this.isModuleInstalled("admin","documents")) { diff --git a/ext/modules/employees/customTemplates/myDetails.html b/ext/modules/employees/customTemplates/myDetails.html index e3775212..77dba539 100644 --- a/ext/modules/employees/customTemplates/myDetails.html +++ b/ext/modules/employees/customTemplates/myDetails.html @@ -167,14 +167,7 @@
-
-

Other Details

-
-
-
-
-
@@ -214,4 +207,4 @@ - \ No newline at end of file + diff --git a/ext/modules/employees/lib.js b/ext/modules/employees/lib.js index 6af59380..1ed4686d 100644 --- a/ext/modules/employees/lib.js +++ b/ext/modules/employees/lib.js @@ -292,13 +292,31 @@ EmployeeAdapter.method('modEmployeeGetSuccessCallBack' , function(data) { //Add custom fields if(data.customFields != undefined && data.customFields != null && Object.keys(data.customFields).length > 0) { + + var ct = '
'; var customFieldHtml; for (index in data.customFields) { + + if(!data.customFields[index][1]){ + data.customFields[index][1] = 'Other Details'; + } + + sectionId = data.customFields[index][1].toLocaleLowerCase(); + sectionId = sectionId.replace(' ','_'); + + if($("#cont_"+sectionId).length <= 0){ + //Add section + sectionHtml = sectionTemplate; + sectionHtml = sectionHtml.replace('#_section_#', sectionId); + sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); + $("#customFieldsCont").append($(sectionHtml)); + } + customFieldHtml = ct; customFieldHtml = customFieldHtml.replace('#_label_#', index); - customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index]); - $("#customFields").append($(customFieldHtml)); + customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); + $("#cont_"+sectionId).append($(customFieldHtml)); } }else{ $("#customFieldsCont").remove(); diff --git a/readme.md b/readme.md index b75117ca..4c0643d4 100644 --- a/readme.md +++ b/readme.md @@ -533,10 +533,10 @@ Release note v18.0 * Allow indirect admins to allow travel requests * Adding more languages to Language meta data table * Improvements to report module - * + * Ability to select sections for placing custom fields on employee detail view screen ### Fixes - * Fix: suvordinates are not showing beyond first page issue. + * Fix: subordinates are not showing beyond first page issue. Release note v16.1