Skip to content

Commit

Permalink
Update Guides
Browse files Browse the repository at this point in the history
  • Loading branch information
itadapter committed Jan 21, 2016
1 parent d0a39c6 commit 66ede6c
Show file tree
Hide file tree
Showing 12 changed files with 776 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Guides/WAVE/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Web Applications with Enhanced Views (Web, Pipeline, MVC, Filters etc.)

* Server-side [WAVE Server](Server.md)
* MVC [MVC](MVC.md)
* Client-side Java Script Library [WAVE.js](WVJS.md)
* Client-side Java Script Library [WAVE.js](WVJS/README.md)
19 changes: 19 additions & 0 deletions Guides/WAVE/WVJS/ArrayFunctions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Array functions

##### arrayClear(array)
Delete all elements from `array`.

##### arrayDelete(array, object element): bool
Delete `element` from `array` and return true if `element` was found.

##### arrayShallowCopy(source_array): object
Return new array - copy of `source_array`.

##### arrayWalkable(array)
Provides walking (see WAVE.Walkable) capability for array.

##### groupWalkable(array)
Converts array with {k : {}, v: []} structure to Walkable group operation result (inverse method to Walkable.wGroupToArray).

##### inArray(array, object element): bool
Returns true when `array` contains `element`.
29 changes: 29 additions & 0 deletions Guides/WAVE/WVJS/EventManager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# WAVE.EventManager
Mixin that implements the event-handler mechanism and can be added to any class.

##### eventInvocationSuspendCount: 0
Increase to disable event firing for all events, decrease to enable, events are enabled again when value is <=0. This property is useful for batch updates to suppress many event firings that are not needed.

##### eventBind(evtName, func)
Binds a function to the named event handler.

##### eventUnbind(evtName, func)
Un-Binds a function from the named event handler.

##### eventClear(evtName)
Clears all functions from the named event handler.

##### eventInvoke(evtName)
Invokes all functions bound to the named event handler.

##### eventSinkBind(sink)
Binds a sink instance (an object) that will receive all events dispatched by this manager. The `sink` must have a function called `eventNotify(evtName, sender, args)` that will be invoked.

##### eventSinkUnbind(sink)
Un-Binds an object that received all events from this manager.

##### eventSinkClear()
Clears all objects that cat as event sinks bound to this instance.

##### eventSinks()
Returns a list of sink object that receive event notifications from this manager.
125 changes: 125 additions & 0 deletions Guides/WAVE/WVJS/Field.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Field Class
Record consists of fields and Field represents a FieldDef from server-side NFX.DataAccess.CRUD.Schema on the client side along with view model/controller.

## Field()
Constructor. Initializes a new instance using string field definition and value.
```js
new rec.Field(object fieldDef)
```
### Examples
```js
var rec = new WAVE.RecordModel.Record("ID-123456", function(){
new this.Field({Name: "FirstName", Type: "string", Required: true});
new this.Field({Name: "LastName", Type: "string"});
new this.Field({Name: "Age", Type: "int"});
});
```
```js
var rec = new WAVE.RecordModel.Record("ID-123456");
new rec.Field({Name: "FirstName", Type: "string"});
new rec.Field({Name: "LastName", Type: "string"});
new rec.Field({Name: "Age", Type: "int", Stored: false});
```


## drop()
Deletes this field from the record.


## deferValidation()
Defer or NOT validation event while changing of field’s value.
```js
deferValidation(bool flag)
```
### Examples
```js
var rec = ...
var elog = "";
rec.fldLastName.deferValidation(true);
rec.fldLastName.eventBind(WAVE.EventManager.ANY_EVENT, function(evtType, field, phase){
elog += "|"+evtType + field.name() + phase + field.value();
});
rec.fldLastName.value("Brown");
// elog = "|data-changeLastNamebeforeSmith|data-changeLastNameafterBrown"
```
```js
var rec = ...
var elog = "";
rec.fldLastName.deferValidation(false);
rec.fldLastName.eventBind(WAVE.EventManager.ANY_EVENT, function(evtType, field, phase){
elog += "|"+evtType + field.name() + phase + field.value();
});
rec.fldLastName.value("Brown");
// elog = "|data-changeLastNamebeforeSmith|validateLastNameundefinedBrown|validatedLastNameundefinedBrown|data-changeLastNameafterBrown"
```


## eventBind()
Binds a function to the named event handler on field.
```js
eventBind(string evtName, function handler)
```
| Parameter | Requirement | Description |
| --------- |:-----------:| --------------------------------------------- |
| evtName | required | name of event from WAVE.RecordModel namespace |
| handler | required | callback-function which fires on event |
### Examples
```js
var rec = ...
var elog = "";
rec.eventBind(WAVE.RecordModel.EVT_FIELD_DROP, function(field, phase){
elog += "|" + field.name() + phase;
});
rec.fldLastName.drop();
// elog = |LastNamebefore|LastNameafter
```


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


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


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


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


## 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.
* validationError() - returns error thrown during validation.
### 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});
});

rec.fldB.validated(); // false
rec.fldB.validate();
rec.fldB.validated(); //true
rec.fldB.valid(); // false
var err = rec.fldB.validationError(); // contains: 'B' must have a value
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.



41 changes: 41 additions & 0 deletions Guides/WAVE/WVJS/OperObjFunc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Operations with objects and functions

##### clone(object obj): object
Deep clones data object (not functions).

##### extend(object obj, object ext, bool keepExisting): object
Mixin behavior - extends `obj` with properties of `ext`.
If flag `keepExisting=true` then existing object key is preserved, even if it is null.

##### isArray(object obj): bool
Returns true when the passed parameter is an array, not a map or function.

##### isFunction(object obj): bool
Returns true when the passed parameter is a function, not a map object or an array.

##### isMapOrArray(obj): bool
Returns true when the passed parameter is an array, or map but not a function.

##### isObject(object obj): bool
Returns true when the passed parameter is a map, not an array or function.

##### isSame(object obj1, object obj2): bool
Returns true if both objects represent the same scalar value or complex structure/map that is keys/values of maps/arrays. Nulls are considered equivalent.

##### overrideFunction(function original, function fn): function
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
```

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

## 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.

#### SVG
Provides working with SVG objects.

#### [UTest](UTest.md)
Implementation of unit testing concept.

#### [Walkable](walkable.md)
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)


20 changes: 0 additions & 20 deletions Guides/WAVE/Record/readme.md → Guides/WAVE/WVJS/Record.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ var rec = new WAVE.RecordModel.Record({ID: 'REC-1',
]});
```


### 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});
});

rec.validate();
var allErr = rec.allValidationErrorStrings();
// allErr contains: 'B' must have a value
```


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

Expand Down Expand Up @@ -84,7 +70,6 @@ var d = JSON.stringify(rec.data(true));
// d = {"LastName":"Brown"}
```


## eventBind()
Binds a function to the named event handler on record.
```js
Expand Down Expand Up @@ -126,15 +111,12 @@ var v = rec.fldFirstName.value();
// v = John
```


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


##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.
Expand All @@ -151,5 +133,3 @@ var all = rec.allValidationErrorStrings();
// all contains 'B' must have a value
// all contains 'C' must have a value
```


File renamed without changes.
Loading

0 comments on commit 66ede6c

Please sign in to comment.