Skip to content

Instantly share code, notes, and snippets.

@taburetkin
taburetkin / validation
Last active September 11, 2018 10:35
validation
import getAjax from 'helpers/get-ajax';
export function normalizeValidateRules(rules){
return _.reduce(rules, (memo, value, key) => {
memo[key] = normalizeValidationContext(value);
return memo;
}, {});
}
export function normalizeValidationContext(context){
@taburetkin
taburetkin / edit-model control
Created September 11, 2018 10:33
edit-model control
import ControlWrapper from 'components/controls/wrapper';
//import CollectionView from 'base/collection-view';
import ModelSchema from '../model-schema';
import EditProperty from './edit-property';
export default ControlWrapper.extend({
className:'edit-model-control',
renderAllCustoms: true,
isControlWrapper: false,
validateOnReady: true,
shouldShowError: false,
@taburetkin
taburetkin / edit-model-property control
Created September 11, 2018 10:33
edit-model-property control
import ControlWrapper from 'components/controls/wrapper';
import Input from 'components/controls/input';
import { textView } from 'base/view';
import { validateItem } from 'helpers/validation';
export default ControlWrapper.extend({
shouldShowError: true,
className:'edit-model-property',
constructor(options = {}){
ControlWrapper.apply(this, arguments);
this.mergeOptions(options, ['propertySchema','property']);
@taburetkin
taburetkin / model-schema
Created September 11, 2018 10:34
model-schema
import { betterResult } from 'bbmn/utils';
//import { flat, unflat } from '../../utils/index.js';
// function deepClone(arg = {}){
// return unflat(flat(arg || {}));
// }
export default function ModelSchema(properties = {}){
this.properties = _.reduce(properties, (memo, property, name) => {
memo[name] = this._createProperty(name, property);
return memo;
}, {});
@taburetkin
taburetkin / selector.js
Created September 12, 2018 17:48
selector
import BaseObject from 'base/object';
export default BaseObject.extend({
initialize(opts){
this.mergeOptions(opts,[
'collection', 'multiple',
'getItemKey', 'getItemValue', 'getItemIndex', 'getItemByIndex', 'children',
'initialValue'
]);
this.store = {};
@taburetkin
taburetkin / select.js
Created September 12, 2018 17:50
select
import CollectionView from 'base/collection-view';
import ControlMixin from '../mixin';
import factory from 'components/values/factory';
import UiItem from 'components/ui-item';
import Selector from './selector';
import Control from 'components/controls/control';
const childView = UiItem.extend({
constructor(){
@taburetkin
taburetkin / on-off-slide.less
Last active September 14, 2018 08:35
on-off slide indicator
.on-off-slide-mixin(@glow-selector: glow, @glow-color: #444, @unglow-color: rgba(255,255,255,.2)) {
position:relative;
padding: 0;
width: 1.5em;
box-sizing: content-box;
border-radius: .5em;
border-width: .1em;
border-style: solid;
border-color: @unglow-color;