-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1681 from xaylpq/2.1/feature/1003850
[#1003850] add text masks
- Loading branch information
Showing
12 changed files
with
270 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import CanvasView from 'demoPage/views/CanvasView'; | ||
|
||
export default function() { | ||
// 1. Create form template | ||
const template = | ||
'<div data-fields="tel"></div>' + | ||
'<div data-fields="passport"></div>' + | ||
'<div data-fields="index"></div>' + | ||
'<div data-fields="inn"></div>' + | ||
'<div data-fields="ogrn"></div>' + | ||
'<div data-fields="carnumber"></div>' + | ||
'<div data-fields="email"></div>'; | ||
|
||
// 2. Create form model | ||
const model = new Backbone.Model({ | ||
tel: undefined, | ||
passport: undefined, | ||
index: undefined, | ||
inn: undefined, | ||
ogrn: undefined, | ||
carnumber: undefined, | ||
email: undefined | ||
}); | ||
|
||
// 3. Create view with BackboneFormBehavior and construct form scheme | ||
const View = Marionette.View.extend({ | ||
className: 'layout__vertical-layout', | ||
|
||
template: Handlebars.compile(template), | ||
|
||
behaviors: { | ||
BackboneFormBehavior: { | ||
model, | ||
behaviorClass: Core.form.behaviors.BackboneFormBehavior, | ||
transliteratedFields: { | ||
name: 'alias' | ||
}, // transliteratedFields becomes required-like, and overwrite next property in schema { changeMode: 'blur', autocommit: true, forceCommit: true} | ||
schema() { | ||
return { | ||
tel: { | ||
title: 'tel', | ||
type: 'Text', | ||
helpText: 'Some help information', | ||
autocommit: true, | ||
format: 'PhoneRuMask', | ||
allowEmptyValue: true //turn off required-like behavior for name | ||
}, | ||
passport: { | ||
title: 'passport', | ||
type: 'Text', | ||
helpText: 'Some help information', | ||
autocommit: true, | ||
format: 'PassportRuMask', | ||
allowEmptyValue: true //turn off required-like behavior for name | ||
}, | ||
index: { | ||
title: 'index', | ||
type: 'Text', | ||
helpText: 'Some help information', | ||
autocommit: true, | ||
format: 'IndexRuMask', | ||
allowEmptyValue: true //turn off required-like behavior for name | ||
}, | ||
inn: { | ||
title: 'inn', | ||
type: 'Text', | ||
helpText: 'Some help information', | ||
autocommit: true, | ||
format: 'INNMask', | ||
allowEmptyValue: true //turn off required-like behavior for name | ||
}, | ||
ogrn: { | ||
title: 'ogrn', | ||
type: 'Text', | ||
helpText: 'Some help information', | ||
autocommit: true, | ||
format: 'OGRNMask', | ||
allowEmptyValue: true //turn off required-like behavior for name | ||
}, | ||
carnumber: { | ||
title: 'carnumber', | ||
type: 'Text', | ||
helpText: 'Some help information', | ||
autocommit: true, | ||
format: 'LicensePlateNumberRuMask', | ||
allowEmptyValue: true //turn off required-like behavior for name | ||
}, | ||
email: { | ||
title: 'email', | ||
type: 'Text', | ||
helpText: 'Some help information', | ||
autocommit: true, | ||
format: 'EmailMask', | ||
allowEmptyValue: true //turn off required-like behavior for name | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
// 4. Show created view | ||
return new CanvasView({ | ||
view: new View({ model }) | ||
}); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.