commit
970136d27a
@ -0,0 +1,17 @@
|
||||
package au.com.royalpay.payment.manage.organizations.beans;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Document
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.METHOD})
|
||||
public @interface ProfileDesc {
|
||||
String value();
|
||||
|
||||
String detail() default "";
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package au.com.royalpay.payment.manage.organizations.core;
|
||||
|
||||
import au.com.royalpay.payment.manage.organizations.beans.DefaultClientProfile;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public final class OrgClientProfileUtils {
|
||||
public static final String PROFILE_KEY = "default_client_profile";
|
||||
|
||||
private OrgClientProfileUtils() {
|
||||
}
|
||||
|
||||
public static DefaultClientProfile getOrgProfile(JSONObject org) {
|
||||
String profile = org.getString(PROFILE_KEY);
|
||||
if (profile == null) {
|
||||
return new DefaultClientProfile();
|
||||
}
|
||||
try {
|
||||
return JSON.parseObject(profile).toJavaObject(DefaultClientProfile.class);
|
||||
} catch (JSONException e) {
|
||||
return new DefaultClientProfile();
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyOrgClientDefaultProfile(JSONObject org, JSONObject client) {
|
||||
DefaultClientProfile profile = getOrgProfile(org);
|
||||
profile.applyToClientConfig(client);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
define(['../app', 'angular'], function (app, angular) {
|
||||
'use strict';
|
||||
app.directive('ngInputName', function () {
|
||||
let myNameError = "myName directive error: "
|
||||
|
||||
return {
|
||||
restrict: 'A', // Declares an Attributes Directive.
|
||||
require: 'ngModel', // ngModelController.
|
||||
|
||||
link: function (scope, elem, attrs, ngModel) {
|
||||
if (!ngModel) {
|
||||
return
|
||||
} // no ngModel exists for this element
|
||||
|
||||
// check myName input for proper formatting ex. something/something
|
||||
checkInputFormat(attrs);
|
||||
|
||||
let inputName = attrs.myName.match('^\\w+').pop(); // 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
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
});
|
Loading…
Reference in new issue