Skip to content

Commit

Permalink
Update Guides
Browse files Browse the repository at this point in the history
  • Loading branch information
itadapter committed Jan 22, 2016
1 parent 66ede6c commit ab97024
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 37 deletions.
116 changes: 106 additions & 10 deletions Guides/WAVE/WVJS/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ new rec.Field({Name: "Age", Type: "int", Stored: false});
Deletes this field from the record.


## deferValidation()
## deferValidation(bool dfrvld)
Defer or NOT validation event while changing of field’s value.
```js
deferValidation(bool flag)
```
### Examples
```js
var rec = ...
Expand All @@ -53,6 +50,11 @@ rec.fldLastName.value("Brown");
// elog = "|data-changeLastNamebeforeSmith|validateLastNameundefinedBrown|validatedLastNameundefinedBrown|data-changeLastNameafterBrown"
```

## about()
Returns field's description from field definition.

## displayValue()
Returns string value of field for display in attached controls/views.

## eventBind()
Binds a function to the named event handler on field.
Expand All @@ -74,31 +76,125 @@ rec.fldLastName.drop();
// elog = |LastNamebefore|LastNameafter
```

## applicable(bool aplcbl)
Sets or returns applicable flag.

## applyDefaultValue(bool force)
Applies default value to field and returns it.

## case(string cs)
Sets or returns string case for texboxes.

## controlType(string tp)
Sets or returns field's control type in attached view.

## defaultValue(val)
Sets or returns field's default value.

## description(string desc)
Sets or returns field's description.

## enabled(bool enbld)
Sets or returns enabled flag.

## getOrInferControlType()
Returns control type for the view from schema, or if not available then infers it from field definition.

## hint(val)
Sets or returns hint for field.

## inferControlType()
Infers control type for the view from field definition disregarding ControlType set in schema.

## isEnabled()
Returns true if field is enabled and applicable.

## isGUIModified()
Returns true when this field was modified from an attached control.

## isLookupDict()
Returns true if field has lookup dictionary constraint.

## isModified()
Returns true when this field has been modified.

## isNull()
Returns true if value is null.

## isTypeLogical()
Returns true if field contains boolean data.

## key()
Returns true if field is key.

## kind(string knd)
Sets or returns data kind for textboxes.

## loaded()
Returns true when this field has finished loading.

## lookupDict(object val)
Sets or returns lookup dictionary for field.

## marked(bool mrk)
Sets or returns marked flag.

## minValue/maxValue(val)
Sets or returns minValue/maxValue of field.

## name()
Returns immutable field name.

## password(bool pswrd)
Sets or returns password flag.

## placeholder(string plc)
Sets or returns field's placeholder property.

## preProcessValueFromGUI(val)
Pre-processes value when it is set from GUI, i.e. trim() string field or adjust phone numbers.

## record()
Returns owner record.

## readonly(bool rdnl)
Sets or returns readonly flag.

## required()
Returns true if field is required.

## resetGUIModified()
Resets field's modification from GUI flag.

## resetModified()
Resets field's modification flag.

## resetSchema()
Reverts the field instance to it's original schema definition, firing events.

## setGUIValue(val)
Sets textual value from control into the field value performing necessary adjustments, i.e. may adjust the format of the phone number etc.

## size/minSize(int val)
Sets or returns field's size/minimum size.

## toString()
Returns string like `[fieldType]Field(fieldName = 'fieldValue')`.

## type()
Returns immutable field data type.

## schemaDef()
Returns the the original schema field def. Do not modify its values, use WAVE.clone() if copy is needed.

## stored()
Returns true if field must be stored back in the server (db).


## Validation functions
* valid() - returns true if field has not validation error.
* validate() - validates field and returns true if it is valid.
* validated() - returns true if field has been validated.
* setExternalValidationError(error) - sets external validation error (i.e. from the server side),
* valid() - returns true if field has not validation error,
* validate() - validates field and returns true if it is valid,
* validated() - returns true if field has been validated,
* validationError() - returns error thrown during validation.
### Examples
```js
Expand All @@ -116,10 +212,10 @@ rec.fldB.value("aaaaa");
rec.fldB.valid(); // true
```


## value()
`value()` - then returns field’s value.
`value(object value, bool fromGUI)` - Sets value and modified, validated flags if new value is different from an existing one. `fromGUI` indicates that field is being altered from an attached control.


## visible(bool vsbl)
Sets or returns visible flag.

11 changes: 0 additions & 11 deletions Guides/WAVE/WVJS/OperObjFunc.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,4 @@ Overrides existing function by wrapping in new one. May call base like so:
```js
object.about = WAVE.overrideFun(object.about, function(){ return this.baseFunction() + "overridden" });
```

##### propStrAsObject(object obj, string prop)
Checks object property for string value and if it is then converts it to object (map).
Does nothing if prop does not exist, is null or not a string value.
```js
var o1 = {a: 1, b: '{"c": "yes", "d": "no"}'};
// WAVE.isObject(o1.b)) = false

WAVE.propStrAsObject(o1, "b");
// WAVE.isObject(o1.b)) = true
```

14 changes: 7 additions & 7 deletions Guides/WAVE/WVJS/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# NFX Wave.js
Java Script Client Library

## General-Purpose Functions

## General-Purpose Functions
#### [Array functions](ArrayFunctions.md)
#### [Operations with objects and functions](OperObjFunc.md)
#### [String functions](StringFunctions.md)


## Sub-libraries and mixins
#### [Geometry](geometry.md)
Contains a large number of functions to work with geometry tasks.

#### [EventManager](EventManager.md)
Mixin that implements the event-handler mechanism and can be added to any class.

#### Pay

#### [RecordModel](RecordModel.md)
Contains classes for MVVM pattern implementation.

#### SVG
Provides working with SVG objects.

Expand All @@ -24,12 +30,6 @@ Implementation of unit testing concept.
Mixin that enables function chaining that facilitates lazy evaluation via lambda-functions.


## Record Model
Record model is in the WAVE.RecordModel namespace.

### Classes
##### [Record](Record.md)
##### [Field](Field.md)
##### [RecordView](RecordView.md)


62 changes: 54 additions & 8 deletions Guides/WAVE/WVJS/Record.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ new WAVE.RecordModel.Record(object initVector)
**Notes**
In both cases fields will be named as concatenation string 'fld' and field name from definition.

### Examples
#### Examples
```js
var rec = new WAVE.RecordModel.Record("ID-123456");
```
Expand All @@ -42,6 +42,12 @@ var rec = new WAVE.RecordModel.Record({ID: 'REC-1',
]});
```

## applyDefaultValue(bool force)
Applies default values to all fields.

## csrfToken()
Returns CSRF token supplied by server. This property can not be set on client.

## data()
Returns a map of fields: `{fieldName:fieldValue,...}`.

Expand All @@ -52,7 +58,7 @@ data(bool modifiedOnly, bool includeNonStored)
| ---------------- |:-----------:| ----------------------------------- |
| modifiedOnly | optional | only get fields that have changed |
| includeNonStored | optional | include fields that are not stored |
### Examples
#### Examples
```js
var rec = new WAVE.RecordModel.Record({ID: 'REC-1',
fields: [
Expand All @@ -79,7 +85,7 @@ eventBind(string evtName, function handler)
| --------- |:-----------:| --------------------------------------------- |
| evtName | required | name of event from WAVE.RecordModel namespace |
| handler | required | callback-function which fires on event |
### Examples
#### Examples
```js
var rec = new WAVE.RecordModel.Record("ID-123456", function(){
new this.Field({Name: "FirstName", Type: "string"});
Expand All @@ -99,7 +105,7 @@ Returns a field by its case-insensitive name or null.
```js
fieldByName(string fieldName)
```
### Examples
#### Examples
```js
var rec = new WAVE.RecordModel.Record("ID-123456", function(){
new this.Field({Name: "FirstName", Type: "string"});
Expand All @@ -111,25 +117,65 @@ var v = rec.fldFirstName.value();
// v = John
```

## fields()
Returns copy of fields list.

## formMode()
Returns form mode on the server if one was supplied (i.e. insert|edit). This property can not be set on client.

## ID()
Returns record instance ID.

## isGUIModified()
Returns true is some field has been modified through GUI-attached views.

## isModified()
Returns true is some field has been modified.

## ISOLang()
Returns record ISO language/culture.

## latchAllEvents(int delta)
Changes all eventInvocationSuspendCount on all fields and this record with `delta`.

## loaded()
Returns true when record has finished loading data and constructing fields.

## resetModified()
Resets all field modification flags.

## resetRecord()
Re-initializes the record and all of its fields anew - resetting all flags.

## resetSchema()
Resets all fields schemes.

##toString()
Returns string like `Record[RecID]`.

## Validation functions
* allValidationErrorStrings() - returns all record and field-level validation errors.
* validate() - validates record and returns true is everything is valid.
### Examples
* allValidationErrors() - returns array of all record and field-level validation errors,
* allValidationErrorStrings() - returns all record and field-level validation errors,
* valid() - Returns true if record and all its fields have been validated and valid,
* validate() - validates record and returns true is everything is valid,
* validated() - returns true if record has been validated,
* validationError() - returns rec-level validation error if any.
#### Examples
```js
var rec = new WAVE.RecordModel.Record("1", function(){
new this.Field({Name: "A", Type: "string"});
new this.Field({Name: "B", Type: "string", Required: true});
new this.Field({Name: "C", Type: "int", Required: true});
});
// rec.validated() = false
rec.validate();
// rec.validated() = true
// rec.valid() = false
var all = rec.allValidationErrorStrings();
// all contains 'B' must have a value
// all contains 'C' must have a value
rec.fldB.value("something");
rec.flC.value(1);
// rec.valid() = true
```

Loading

0 comments on commit ab97024

Please sign in to comment.