Merge branch 'develop'

master
yixian 4 years ago
commit 28e436a978

@ -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<JSONObject> 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");

@ -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 + "<Form> 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
}
})

@ -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) {

@ -761,7 +761,7 @@
<form name="profileForm" class="form-horizontal">
<div class="form-group" ng-repeat="field in clientProfileFields">
<label class="control-label col-md-3" ng-bind="field.title"></label>
<label class="control-label col-md-3" ng-bind="field.title||field.field"></label>
<div class="col-md-7" ng-class="{'checkbox-inline':field.type=='checkbox'}">
<input ng-class="{'checkbox':field.type=='checkbox','form-control':field.type!='checkbox'}"
ng-model="field.value" ng-input-name="{{field.field}}" type="{{field.type}}">
@ -769,8 +769,10 @@
</div>
</div>
</form>
<button class="btn btn-warning"><i class="fa fa-refresh"></i> Reset</button>
<button class="btn btn-success"><i class="fa fa-check"></i> Submit</button>
<button class="btn btn-warning" ng-click="loadClientProfile()"><i class="fa fa-refresh"></i> Reset
</button>
<button class="btn btn-success" ng-click="submitClientProfile()"><i class="fa fa-check"></i> Submit
</button>
</uib-tab>
</uib-tabset>
</div>

Loading…
Cancel
Save