model.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. import isEqual from 'lodash/isEqual';
  2. import {action, computed, makeObservable, observable, ObservableMap} from 'mobx';
  3. import {addErrorMessage, saveOnBlurUndoMessage} from 'sentry/actionCreators/indicator';
  4. import {APIRequestMethod, Client} from 'sentry/api';
  5. import FormState from 'sentry/components/forms/state';
  6. import {t} from 'sentry/locale';
  7. import type {Choice} from 'sentry/types';
  8. import {defined} from 'sentry/utils';
  9. type Snapshot = Map<string, FieldValue>;
  10. type SaveSnapshot = (() => number) | null;
  11. export type FieldValue = string | number | boolean | Choice | undefined; // is undefined valid here?
  12. export type FormOptions = {
  13. allowUndo?: boolean;
  14. apiEndpoint?: string;
  15. apiMethod?: APIRequestMethod;
  16. onFieldChange?: (id: string, finalValue: FieldValue) => void;
  17. onSubmitError?: (error: any, instance: FormModel, id?: string) => void;
  18. onSubmitSuccess?: (
  19. response: any,
  20. instance: FormModel,
  21. id?: string,
  22. change?: {new: FieldValue; old: FieldValue}
  23. ) => void;
  24. resetOnError?: boolean;
  25. saveOnBlur?: boolean;
  26. };
  27. type ClientOptions = ConstructorParameters<typeof Client>[0];
  28. type OptionsWithInitial = FormOptions & {
  29. apiOptions?: ClientOptions;
  30. initialData?: Record<string, FieldValue>;
  31. };
  32. class FormModel {
  33. /**
  34. * Map of field name -> value
  35. */
  36. fields: ObservableMap<string, FieldValue> = observable.map();
  37. /**
  38. * Errors for individual fields
  39. * Note we don't keep error in `this.fieldState` so that we can easily
  40. * See if the form is in an "error" state with the `isError` getter
  41. */
  42. errors = new Map();
  43. /**
  44. * State of individual fields
  45. *
  46. * Map of field name -> object
  47. */
  48. fieldState = new Map();
  49. /**
  50. * State of the form as a whole
  51. */
  52. formState: FormState | undefined;
  53. /**
  54. * Holds field properties as declared in <Form>
  55. * Does not need to be observable since these props should never change
  56. */
  57. fieldDescriptor = new Map();
  58. /**
  59. * Holds a list of `fields` states
  60. */
  61. snapshots: Array<Snapshot> = [];
  62. /**
  63. * POJO of field name -> value
  64. * It holds field values "since last save"
  65. */
  66. initialData: Record<string, FieldValue> = {};
  67. api: Client;
  68. formErrors: any;
  69. options: FormOptions;
  70. constructor({initialData, apiOptions, ...options}: OptionsWithInitial = {}) {
  71. makeObservable(this, {
  72. fields: observable,
  73. errors: observable,
  74. fieldState: observable,
  75. formState: observable,
  76. isError: computed,
  77. isSaving: computed,
  78. formData: computed,
  79. formChanged: computed,
  80. resetForm: action,
  81. setFieldDescriptor: action,
  82. removeField: action,
  83. setValue: action,
  84. validateField: action,
  85. updateShowSaveState: action,
  86. updateShowReturnButtonState: action,
  87. undo: action,
  88. saveForm: action,
  89. saveField: action,
  90. saveFieldRequest: action,
  91. handleBlurField: action,
  92. setFormSaving: action,
  93. handleSaveField: action,
  94. handleCancelSaveField: action,
  95. setFieldState: action,
  96. setSaving: action,
  97. setError: action,
  98. validateForm: action,
  99. handleErrorResponse: action,
  100. submitSuccess: action,
  101. submitError: action,
  102. });
  103. this.options = options ?? {};
  104. if (initialData) {
  105. this.setInitialData(initialData);
  106. }
  107. this.api = new Client(apiOptions);
  108. }
  109. /**
  110. * Reset state of model
  111. */
  112. reset() {
  113. this.api.clear();
  114. this.fieldDescriptor.clear();
  115. this.resetForm();
  116. }
  117. resetForm() {
  118. this.fields.clear();
  119. this.errors.clear();
  120. this.fieldState.clear();
  121. this.snapshots = [];
  122. this.initialData = {};
  123. }
  124. /**
  125. * Deep equality comparison between last saved state and current fields state
  126. */
  127. get formChanged() {
  128. return !isEqual(this.initialData, Object.fromEntries(this.fields.toJSON()));
  129. }
  130. get formData() {
  131. return this.fields;
  132. }
  133. /**
  134. * Is form saving
  135. */
  136. get isSaving() {
  137. return this.formState === FormState.SAVING;
  138. }
  139. /**
  140. * Does form have any errors
  141. */
  142. get isError() {
  143. return !!this.errors.size;
  144. }
  145. /**
  146. * Sets initial form data
  147. *
  148. * Also resets snapshots
  149. */
  150. setInitialData(initialData?: Record<string, FieldValue>) {
  151. this.fields.replace(initialData || {});
  152. this.initialData = Object.fromEntries(this.fields.toJSON()) || {};
  153. this.snapshots = [new Map(this.fields.entries())];
  154. }
  155. /**
  156. * Set form options
  157. */
  158. setFormOptions(options: FormOptions) {
  159. this.options = options || {};
  160. }
  161. /**
  162. * Set field properties
  163. */
  164. setFieldDescriptor(id: string, props) {
  165. // TODO(TS): add type to props
  166. this.fieldDescriptor.set(id, props);
  167. // Set default value iff initialData for field is undefined
  168. // This must take place before checking for `props.setValue` so that it can
  169. // be applied to `defaultValue`
  170. if (
  171. typeof props.defaultValue !== 'undefined' &&
  172. typeof this.initialData[id] === 'undefined'
  173. ) {
  174. this.initialData[id] =
  175. typeof props.defaultValue === 'function'
  176. ? props.defaultValue()
  177. : props.defaultValue;
  178. this.fields.set(id, this.initialData[id]);
  179. }
  180. if (typeof props.setValue === 'function') {
  181. this.initialData[id] = props.setValue(this.initialData[id], props);
  182. this.fields.set(id, this.initialData[id]);
  183. }
  184. }
  185. /**
  186. * Remove a field from the descriptor map and errors.
  187. */
  188. removeField(id: string) {
  189. this.fieldDescriptor.delete(id);
  190. this.errors.delete(id);
  191. }
  192. /**
  193. * Creates a cloned Map of `this.fields` and returns a closure that when called
  194. * will save Map to `snapshots
  195. */
  196. createSnapshot() {
  197. const snapshot = new Map(this.fields.entries());
  198. return () => this.snapshots.unshift(snapshot);
  199. }
  200. getDescriptor(id: string, key: string) {
  201. // Needs to call `has` or else component will not be reactive if `id` doesn't exist in observable map
  202. const descriptor = this.fieldDescriptor.has(id) && this.fieldDescriptor.get(id);
  203. if (!descriptor) {
  204. return null;
  205. }
  206. return descriptor[key];
  207. }
  208. getFieldState(id: string, key: string) {
  209. // Needs to call `has` or else component will not be reactive if `id` doesn't exist in observable map
  210. const fieldState = this.fieldState.has(id) && this.fieldState.get(id);
  211. if (!fieldState) {
  212. return null;
  213. }
  214. return fieldState[key];
  215. }
  216. getValue(id: string) {
  217. return this.fields.has(id) ? this.fields.get(id) : '';
  218. }
  219. getTransformedValue(id: string) {
  220. const fieldDescriptor = this.fieldDescriptor.get(id);
  221. const transformer =
  222. fieldDescriptor && typeof fieldDescriptor.getValue === 'function'
  223. ? fieldDescriptor.getValue
  224. : null;
  225. const value = this.getValue(id);
  226. return transformer ? transformer(value) : value;
  227. }
  228. /**
  229. * Data represented in UI
  230. */
  231. getData() {
  232. return Object.fromEntries(this.fields.toJSON());
  233. }
  234. /**
  235. * Form data that will be sent to API endpoint (i.e. after transforms)
  236. */
  237. getTransformedData() {
  238. const form = this.getData();
  239. return Object.keys(form)
  240. .map(id => [id, this.getTransformedValue(id)])
  241. .reduce((acc, [id, value]) => {
  242. acc[id] = value;
  243. return acc;
  244. }, {});
  245. }
  246. getError(id: string) {
  247. return this.errors.has(id) && this.errors.get(id);
  248. }
  249. /**
  250. * Returns true if not required or is required and is not empty
  251. */
  252. isValidRequiredField(id: string) {
  253. // Check field descriptor to see if field is required
  254. const isRequired = this.getDescriptor(id, 'required');
  255. const value = this.getValue(id);
  256. return !isRequired || (value !== '' && defined(value));
  257. }
  258. isValidField(id: string) {
  259. return (this.getError(id) || []).length === 0;
  260. }
  261. doApiRequest({
  262. apiEndpoint,
  263. apiMethod,
  264. data,
  265. }: {
  266. data: object;
  267. apiEndpoint?: string;
  268. apiMethod?: APIRequestMethod;
  269. }) {
  270. const endpoint = apiEndpoint || this.options.apiEndpoint || '';
  271. const method = apiMethod || this.options.apiMethod;
  272. return new Promise((resolve, reject) =>
  273. this.api.request(endpoint, {
  274. method,
  275. data,
  276. success: response => resolve(response),
  277. error: error => reject(error),
  278. })
  279. );
  280. }
  281. /**
  282. * Set the value of the form field
  283. * if quiet is true, we skip callbacks, validations
  284. */
  285. setValue(id: string, value: FieldValue, {quiet}: {quiet?: boolean} = {}) {
  286. const fieldDescriptor = this.fieldDescriptor.get(id);
  287. let finalValue = value;
  288. if (fieldDescriptor && typeof fieldDescriptor.transformInput === 'function') {
  289. finalValue = fieldDescriptor.transformInput(value);
  290. }
  291. this.fields.set(id, finalValue);
  292. if (quiet) {
  293. return;
  294. }
  295. if (this.options.onFieldChange) {
  296. this.options.onFieldChange(id, finalValue);
  297. }
  298. this.validateField(id);
  299. this.updateShowSaveState(id, finalValue);
  300. this.updateShowReturnButtonState(id, finalValue);
  301. }
  302. validateField(id: string) {
  303. const validate = this.getDescriptor(id, 'validate');
  304. let errors: any[] = [];
  305. if (typeof validate === 'function') {
  306. // Returns "tuples" of [id, error string]
  307. errors = validate({model: this, id, form: this.getData()}) || [];
  308. }
  309. const fieldIsRequiredMessage = t('Field is required');
  310. if (!this.isValidRequiredField(id)) {
  311. errors.push([id, fieldIsRequiredMessage]);
  312. }
  313. // If we have no errors, ensure we clear the field
  314. errors = errors.length === 0 ? [[id, null]] : errors;
  315. errors.forEach(([field, errorMessage]) => this.setError(field, errorMessage));
  316. return undefined;
  317. }
  318. updateShowSaveState(id: string, value: FieldValue) {
  319. const isValueChanged = value !== this.initialData[id];
  320. // Update field state to "show save" if save on blur is disabled for this field
  321. // (only if contents of field differs from initial value)
  322. const saveOnBlurFieldOverride = this.getDescriptor(id, 'saveOnBlur');
  323. if (typeof saveOnBlurFieldOverride === 'undefined' || saveOnBlurFieldOverride) {
  324. return;
  325. }
  326. if (this.getFieldState(id, 'showSave') === isValueChanged) {
  327. return;
  328. }
  329. this.setFieldState(id, 'showSave', isValueChanged);
  330. }
  331. updateShowReturnButtonState(id: string, value: FieldValue) {
  332. const isValueChanged = value !== this.initialData[id];
  333. const shouldShowReturnButton = this.getDescriptor(id, 'showReturnButton');
  334. if (!shouldShowReturnButton) {
  335. return;
  336. }
  337. // Only update state if state has changed
  338. if (this.getFieldState(id, 'showReturnButton') === isValueChanged) {
  339. return;
  340. }
  341. this.setFieldState(id, 'showReturnButton', isValueChanged);
  342. }
  343. /**
  344. * Changes form values to previous saved state
  345. */
  346. undo() {
  347. // Always have initial data snapshot
  348. if (this.snapshots.length < 2) {
  349. return null;
  350. }
  351. this.snapshots.shift();
  352. this.fields.replace(this.snapshots[0]);
  353. return true;
  354. }
  355. /**
  356. * Attempts to save entire form to server and saves a snapshot for undos
  357. */
  358. saveForm() {
  359. if (!this.validateForm()) {
  360. return null;
  361. }
  362. let saveSnapshot: SaveSnapshot = this.createSnapshot();
  363. const request = this.doApiRequest({
  364. data: this.getTransformedData(),
  365. });
  366. this.setFormSaving();
  367. request
  368. .then(resp => {
  369. // save snapshot
  370. if (saveSnapshot) {
  371. saveSnapshot();
  372. saveSnapshot = null;
  373. }
  374. if (this.options.onSubmitSuccess) {
  375. this.options.onSubmitSuccess(resp, this);
  376. }
  377. })
  378. .catch(resp => {
  379. // should we revert field value to last known state?
  380. saveSnapshot = null;
  381. if (this.options.resetOnError) {
  382. this.setInitialData({});
  383. }
  384. this.submitError(resp);
  385. if (this.options.onSubmitError) {
  386. this.options.onSubmitError(resp, this);
  387. }
  388. });
  389. return request;
  390. }
  391. /**
  392. * Attempts to save field and show undo message if necessary.
  393. * Calls submit handlers.
  394. * TODO(billy): This should return a promise that resolves (instead of null)
  395. */
  396. saveField(id: string, currentValue: FieldValue) {
  397. const oldValue = this.initialData[id];
  398. const savePromise = this.saveFieldRequest(id, currentValue);
  399. if (!savePromise) {
  400. return null;
  401. }
  402. return savePromise
  403. .then(resp => {
  404. const newValue = this.getValue(id);
  405. const change = {old: oldValue, new: newValue};
  406. // Only use `allowUndo` option if explicitly defined
  407. if (typeof this.options.allowUndo === 'undefined' || this.options.allowUndo) {
  408. saveOnBlurUndoMessage(change, this, id);
  409. }
  410. if (this.options.onSubmitSuccess) {
  411. this.options.onSubmitSuccess(resp, this, id, change);
  412. }
  413. return resp;
  414. })
  415. .catch(error => {
  416. if (this.options.onSubmitError) {
  417. this.options.onSubmitError(error, this, id);
  418. }
  419. return {};
  420. });
  421. }
  422. /**
  423. * Saves a field with new value
  424. *
  425. * If field has changes, field does not have errors, then it will:
  426. * Save a snapshot, apply any data transforms, perform api request.
  427. *
  428. * If successful then: 1) reset save state, 2) update `initialData`, 3) save snapshot
  429. * If failed then: 1) reset save state, 2) add error state
  430. */
  431. saveFieldRequest(id: string, currentValue: FieldValue) {
  432. const initialValue = this.initialData[id];
  433. // Don't save if field hasn't changed
  434. // Don't need to check for error state since initialData wouldn't have updated since last error
  435. if (
  436. currentValue === initialValue ||
  437. (currentValue === '' && !defined(initialValue))
  438. ) {
  439. return null;
  440. }
  441. // Check for error first
  442. this.validateField(id);
  443. if (!this.isValidField(id)) {
  444. return null;
  445. }
  446. // shallow clone fields
  447. let saveSnapshot: SaveSnapshot = this.createSnapshot();
  448. // Save field + value
  449. this.setSaving(id, true);
  450. const fieldDescriptor = this.fieldDescriptor.get(id);
  451. // Check if field needs to handle transforming request object
  452. const getData =
  453. typeof fieldDescriptor.getData === 'function' ? fieldDescriptor.getData : a => a;
  454. const request = this.doApiRequest({
  455. data: getData(
  456. {[id]: this.getTransformedValue(id)},
  457. {model: this, id, form: this.getData()}
  458. ),
  459. });
  460. request
  461. .then(data => {
  462. this.setSaving(id, false);
  463. // save snapshot
  464. if (saveSnapshot) {
  465. saveSnapshot();
  466. saveSnapshot = null;
  467. }
  468. // Update initialData after successfully saving a field as it will now be the baseline value
  469. this.initialData[id] = this.getValue(id);
  470. return data;
  471. })
  472. .catch(resp => {
  473. // should we revert field value to last known state?
  474. saveSnapshot = null;
  475. // Field can be configured to reset on error
  476. // e.g. BooleanFields
  477. const shouldReset = this.getDescriptor(id, 'resetOnError');
  478. if (shouldReset) {
  479. this.setValue(id, initialValue);
  480. }
  481. // API can return a JSON object with either:
  482. // 1) map of {[fieldName] => Array<ErrorMessages>}
  483. // 2) {'non_field_errors' => Array<ErrorMessages>}
  484. if (resp && resp.responseJSON) {
  485. // non-field errors can be camelcase or snake case
  486. const nonFieldErrors =
  487. resp.responseJSON.non_field_errors || resp.responseJSON.nonFieldErrors;
  488. // find the first entry with an error
  489. const firstError = Object.entries(resp.responseJSON).find(
  490. ([_, v]) => Array.isArray(v) && v.length
  491. )?.[1] as string | boolean | undefined;
  492. // Show resp msg from API endpoint if possible
  493. if (Array.isArray(resp.responseJSON[id]) && resp.responseJSON[id].length) {
  494. // Just take first resp for now
  495. this.setError(id, resp.responseJSON[id][0]);
  496. } else if (Array.isArray(nonFieldErrors) && nonFieldErrors.length) {
  497. addErrorMessage(nonFieldErrors[0], {duration: 10000});
  498. // Reset saving state
  499. this.setError(id, '');
  500. } else if (firstError) {
  501. this.setError(id, firstError);
  502. } else {
  503. this.setError(id, 'Failed to save');
  504. }
  505. } else {
  506. // Default error behavior
  507. this.setError(id, 'Failed to save');
  508. }
  509. // eslint-disable-next-line no-console
  510. console.error('Error saving form field', resp && resp.responseJSON);
  511. });
  512. return request;
  513. }
  514. /**
  515. * This is called when a field is blurred
  516. *
  517. * If `saveOnBlur` is set then call `saveField` and handle form callbacks accordingly
  518. */
  519. handleBlurField(id: string, currentValue: FieldValue) {
  520. // Nothing to do if `saveOnBlur` is not on
  521. if (!this.options.saveOnBlur) {
  522. return null;
  523. }
  524. // Fields can individually set `saveOnBlur` to `false` (note this is ignored when `undefined`)
  525. const saveOnBlurFieldOverride = this.getDescriptor(id, 'saveOnBlur');
  526. if (typeof saveOnBlurFieldOverride !== 'undefined' && !saveOnBlurFieldOverride) {
  527. return null;
  528. }
  529. return this.saveField(id, currentValue);
  530. }
  531. setFormSaving() {
  532. this.formState = FormState.SAVING;
  533. }
  534. /**
  535. * This is called when a field does not saveOnBlur and has an individual "Save" button
  536. */
  537. handleSaveField(id: string, currentValue: FieldValue) {
  538. const savePromise = this.saveField(id, currentValue);
  539. if (!savePromise) {
  540. return null;
  541. }
  542. return savePromise.then(() => {
  543. this.setFieldState(id, 'showSave', false);
  544. });
  545. }
  546. /**
  547. * Cancel "Save Field" state and revert form value back to initial value
  548. */
  549. handleCancelSaveField(id: string) {
  550. this.setValue(id, this.initialData[id]);
  551. this.setFieldState(id, 'showSave', false);
  552. }
  553. setFieldState(id: string, key: string, value: FieldValue) {
  554. const state = {
  555. ...(this.fieldState.get(id) || {}),
  556. [key]: value,
  557. };
  558. this.fieldState.set(id, state);
  559. }
  560. /**
  561. * Set "saving" state for field
  562. */
  563. setSaving(id: string, value: FieldValue) {
  564. // When saving, reset error state
  565. this.setError(id, false);
  566. this.setFieldState(id, FormState.SAVING, value);
  567. this.setFieldState(id, FormState.READY, !value);
  568. }
  569. /**
  570. * Set "error" state for field
  571. */
  572. setError(id: string, error: boolean | string) {
  573. // Note we don't keep error in `this.fieldState` so that we can easily
  574. // See if the form is in an "error" state with the `isError` getter
  575. if (error) {
  576. this.formState = FormState.ERROR;
  577. this.errors.set(id, error);
  578. } else {
  579. this.formState = FormState.READY;
  580. this.errors.delete(id);
  581. }
  582. // Field should no longer to "saving", but is not necessarily "ready"
  583. this.setFieldState(id, FormState.SAVING, false);
  584. }
  585. /**
  586. * Returns true if there are no errors
  587. */
  588. validateForm(): boolean {
  589. Array.from(this.fieldDescriptor.keys()).forEach(id => !this.validateField(id));
  590. return !this.isError;
  591. }
  592. handleErrorResponse({responseJSON: resp}: {responseJSON?: any} = {}) {
  593. if (!resp) {
  594. return;
  595. }
  596. // Show resp msg from API endpoint if possible
  597. Object.keys(resp).forEach(id => {
  598. // non-field errors can be camelcase or snake case
  599. const nonFieldErrors = resp.non_field_errors || resp.nonFieldErrors;
  600. if (
  601. (id === 'non_field_errors' || id === 'nonFieldErrors') &&
  602. Array.isArray(nonFieldErrors) &&
  603. nonFieldErrors.length
  604. ) {
  605. addErrorMessage(nonFieldErrors[0], {duration: 10000});
  606. } else if (Array.isArray(resp[id]) && resp[id].length) {
  607. // Just take first resp for now
  608. this.setError(id, resp[id][0]);
  609. }
  610. });
  611. }
  612. submitSuccess(data: Record<string, FieldValue>) {
  613. // update initial data
  614. this.formState = FormState.READY;
  615. this.initialData = data;
  616. }
  617. submitError(err: {responseJSON?: any}) {
  618. this.formState = FormState.ERROR;
  619. this.formErrors = this.mapFormErrors(err.responseJSON);
  620. this.handleErrorResponse({responseJSON: this.formErrors});
  621. }
  622. mapFormErrors(responseJSON?: any) {
  623. return responseJSON;
  624. }
  625. }
  626. /**
  627. * The mock model mocks the model interface to simply return values from the props
  628. *
  629. * This is valuable for using form fields outside of a Form context. Disables a
  630. * lot of functionality however.
  631. */
  632. export class MockModel {
  633. // TODO(TS)
  634. props: any;
  635. initialData: Record<string, FieldValue>;
  636. constructor(props) {
  637. this.props = props;
  638. this.initialData = {
  639. [props.name]: props.value,
  640. };
  641. }
  642. setValue() {}
  643. setFieldDescriptor() {}
  644. removeField() {}
  645. handleBlurField() {}
  646. getValue() {
  647. return this.props.value;
  648. }
  649. getError() {
  650. return this.props.error;
  651. }
  652. getFieldState() {
  653. return false;
  654. }
  655. }
  656. export default FormModel;