rerobe-js-orm 2.9.1 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FormStateFactory from '../FormStateFactory';
|
|
2
2
|
import UserFormState from '../../../form-states/User/UserFormState';
|
|
3
3
|
export default class UserFormStateFactory extends FormStateFactory {
|
|
4
|
-
createFormState(props?: UserAttributes): UserFormState;
|
|
4
|
+
createFormState(props?: UserAttributes, opts?: any): UserFormState;
|
|
5
5
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const FormStateFactory_1 = require("../FormStateFactory");
|
|
4
4
|
const UserFormState_1 = require("../../../form-states/User/UserFormState");
|
|
5
5
|
class UserFormStateFactory extends FormStateFactory_1.default {
|
|
6
|
-
createFormState(props) {
|
|
7
|
-
return new UserFormState_1.default(props);
|
|
6
|
+
createFormState(props, opts) {
|
|
7
|
+
return new UserFormState_1.default(props, opts);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
exports.default = UserFormStateFactory;
|
|
@@ -3,7 +3,10 @@ import User from '../../models/User';
|
|
|
3
3
|
export default class UserFormState extends FormState {
|
|
4
4
|
fields: UserFormFields;
|
|
5
5
|
props: UserAttributes;
|
|
6
|
-
|
|
6
|
+
opts: {
|
|
7
|
+
tagOptions: string[];
|
|
8
|
+
};
|
|
9
|
+
constructor(props?: any, opts?: any);
|
|
7
10
|
createUser(): User;
|
|
8
11
|
private fieldFactory;
|
|
9
12
|
}
|
|
@@ -4,9 +4,10 @@ const FormState_1 = require("../FormState");
|
|
|
4
4
|
const User_1 = require("../../models/User");
|
|
5
5
|
const UserFromFormState_1 = require("../../factories/User/UserFromFormState");
|
|
6
6
|
class UserFormState extends FormState_1.default {
|
|
7
|
-
constructor(props) {
|
|
7
|
+
constructor(props, opts) {
|
|
8
8
|
super();
|
|
9
9
|
this.props = new User_1.default(props).toObj();
|
|
10
|
+
this.opts = opts;
|
|
10
11
|
this.fields.firstName = this.fieldFactory('textInput', 'firstName');
|
|
11
12
|
this.fields.lastName = this.fieldFactory('textInput', 'lastName');
|
|
12
13
|
this.fields.email = this.fieldFactory('textInput', 'email');
|
|
@@ -27,7 +28,6 @@ class UserFormState extends FormState_1.default {
|
|
|
27
28
|
return userFactory.createUser(this);
|
|
28
29
|
}
|
|
29
30
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
30
|
-
var _a;
|
|
31
31
|
let options = fieldOptions || [];
|
|
32
32
|
let editOptionsHandler = () => null;
|
|
33
33
|
if (fieldType === 'textInput' &&
|
|
@@ -99,8 +99,16 @@ class UserFormState extends FormState_1.default {
|
|
|
99
99
|
editOptionsHandler = (oldVal, val) => this.editExistingOption('billing', oldVal, val);
|
|
100
100
|
}
|
|
101
101
|
if (fieldKey === 'tags') {
|
|
102
|
+
let selectedTagOptions = [];
|
|
103
|
+
if (this.props.tags && Array.isArray(this.props.tags) && this.props.tags.length > 0) {
|
|
104
|
+
selectedTagOptions = this.props.tags.map((t) => ({ label: t, value: t }));
|
|
105
|
+
}
|
|
106
|
+
let tagOptions = [];
|
|
107
|
+
if (this.opts && this.opts.tagOptions && this.opts.tagOptions.length > 0) {
|
|
108
|
+
tagOptions = this.opts.tagOptions.map((t) => ({ label: t, value: t }));
|
|
109
|
+
}
|
|
102
110
|
selectedValues = this.props.tags || [];
|
|
103
|
-
options =
|
|
111
|
+
options = this.utilities.uniqObjArray([...selectedTagOptions, ...tagOptions], 'value');
|
|
104
112
|
valid = true;
|
|
105
113
|
}
|
|
106
114
|
return {
|