From ae3359dcc4c4b864a981d7e975fb79e0ad5da37e Mon Sep 17 00:00:00 2001 From: yixian Date: Wed, 29 Jul 2020 02:34:03 +1000 Subject: [PATCH] fixed ui bug --- .../beans/DefaultClientProfile.java | 9 ++++-- .../static/commons/directives/ngInputName.js | 28 ++++--------------- .../config/organizations/organizations.js | 4 +-- .../organizations/templates/org_detail.html | 8 ++++-- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/DefaultClientProfile.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/DefaultClientProfile.java index c37355222..08a049156 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/DefaultClientProfile.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/DefaultClientProfile.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.annotation.JSONType; import com.google.common.base.CaseFormat; import com.yixsoft.support.mybatis.utils.ClassFieldsDescription; import com.yixsoft.support.mybatis.utils.FieldDescription; +import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.ObjectUtils; import org.hibernate.validator.constraints.Range; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -32,6 +33,7 @@ public class DefaultClientProfile { public List desc() { return new ClassFieldsDescription<>(getClass()).getFields().stream() + .filter(field -> !"class".equalsIgnoreCase(field.getFieldName())) .map(this::convertFieldInfo) .collect(Collectors.toList()); } @@ -43,8 +45,11 @@ public class DefaultClientProfile { info.put("field", fieldName); info.put("value", value); Class fieldType = field.getMethod().getReturnType(); - if (fieldType.isPrimitive()) { - if (fieldType.equals(Boolean.class)) { + if (ClassUtils.isPrimitiveOrWrapper(fieldType)) { + if (ClassUtils.isPrimitiveWrapper(fieldType)) { + fieldType = ClassUtils.wrapperToPrimitive(fieldType); + } + if (fieldType.equals(boolean.class)) { info.put("type", "checkbox"); } else { info.put("type", "number"); diff --git a/src/main/ui/static/commons/directives/ngInputName.js b/src/main/ui/static/commons/directives/ngInputName.js index 8318fb2aa..c5ee53b80 100644 --- a/src/main/ui/static/commons/directives/ngInputName.js +++ b/src/main/ui/static/commons/directives/ngInputName.js @@ -1,7 +1,7 @@ define(['../app', 'angular'], function (app, angular) { 'use strict'; app.directive('ngInputName', function () { - let myNameError = "myName directive error: " + let myNameError = "ngInputName directive error: " return { restrict: 'A', // Declares an Attributes Directive. @@ -15,40 +15,22 @@ define(['../app', 'angular'], function (app, angular) { // check myName input for proper formatting ex. something/something checkInputFormat(attrs); - let inputName = attrs.myName.match('^\\w+').pop(); // match upto '/' + let inputName = attrs.ngInputName; // match upto '/' assignInputNameToInputModel(inputName, ngModel); - let formName = attrs.myName.match('\\w+$').pop(); // match after '/' - findForm(formName, ngModel, scope); + } // end link } // end return function checkInputFormat(attrs) { - if (!/\w\/\w/.test(attrs.rsName)) { - throw myNameError + "Formatting should be \"inputName/formName\" but is " + attrs.rsName + if (!/\w/.test(attrs.ngInputName)) { + throw myNameError + "Formatting should be \"inputName\" but is " + attrs.ngInputName } } function assignInputNameToInputModel(inputName, ngModel) { ngModel.$name = inputName } - - function addInputNameToForm(formName, ngModel, scope) { - scope[formName][ngModel.$name] = ngModel; - return - } - - function findForm(formName, ngModel, scope) { - if (!scope) { // ran out of scope before finding scope[formName] - throw myNameError + "
element named " + formName + " could not be found." - } - - if (formName in scope) { // found scope[formName] - addInputNameToForm(formName, ngModel, scope) - return - } - findForm(formName, ngModel, scope.$parent) // recursively search through $parent scopes - } }) diff --git a/src/main/ui/static/config/organizations/organizations.js b/src/main/ui/static/config/organizations/organizations.js index bfdd4a5d3..63c43a937 100644 --- a/src/main/ui/static/config/organizations/organizations.js +++ b/src/main/ui/static/config/organizations/organizations.js @@ -131,7 +131,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.loadTransactionAmountInOrg(); }; $scope.loadClientProfile = function () { - $http.get('/sys/orgs/' + $scope.org.org_id + '/default_client_profile').then(function (res) { + $http.get('/sys/orgs/' + org.data.org_id + '/default_client_profile').then(function (res) { $scope.clientProfileFields = res.data; }) }; @@ -141,7 +141,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { for (let field of $scope.clientProfileFields) { profile[field.field] = field.value; } - $http.put('/sys/orgs/' + $scope.org.org_id + '/default_client_profile').then(function () { + $http.put('/sys/orgs/' + org.data.org_id + '/default_client_profile', profile).then(function () { commonDialog.alert({type: 'success', title: 'Success', content: 'Modify Success'}); $scope.loadClientProfile(); }, function (res) { diff --git a/src/main/ui/static/config/organizations/templates/org_detail.html b/src/main/ui/static/config/organizations/templates/org_detail.html index 22f89651b..7f95fc1b4 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail.html +++ b/src/main/ui/static/config/organizations/templates/org_detail.html @@ -761,7 +761,7 @@
- +
@@ -769,8 +769,10 @@
- - + +