2018-08-04 21:46:25 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var MVocabulary = require("./vocabulary");
|
|
|
|
|
|
|
|
var Address = require("../../wType/address");
|
|
|
|
var Boolean = require("../../wType/boolean");
|
2018-11-28 06:54:14 +00:00
|
|
|
var Uint64 = require("../../wType/uint64");
|
|
|
|
var String = require("../../wType/string");
|
|
|
|
var Vocabulary = require("../../wType/vocabulary");
|
|
|
|
var Vector = require("../../wType/vector");
|
2018-08-04 21:46:25 +00:00
|
|
|
|
|
|
|
var Pane = MVocabulary.inherit({
|
|
|
|
"className": "Pane",
|
2018-11-28 06:54:14 +00:00
|
|
|
"constructor": function(address, controllerAddress, socket, actions) {
|
2018-08-04 21:46:25 +00:00
|
|
|
MVocabulary.fn.constructor.call(this, address, controllerAddress, socket);
|
|
|
|
|
2018-11-28 06:54:14 +00:00
|
|
|
this._actions = new Vector();
|
|
|
|
this._createActions(actions || []);
|
2018-08-04 21:46:25 +00:00
|
|
|
if (this.constructor.pageAddress) {
|
|
|
|
this.hasPageLink = true;
|
|
|
|
|
|
|
|
var id = address.back();
|
|
|
|
this._pageLink = this.constructor.pageAddress["+"](new Address([id.toString()]));
|
|
|
|
}
|
|
|
|
},
|
2018-11-28 06:54:14 +00:00
|
|
|
"destructor": function() {
|
|
|
|
this._actions.destructor();
|
|
|
|
if (this.hasPageLink) {
|
|
|
|
this._pageLink.destructor();
|
|
|
|
}
|
|
|
|
|
|
|
|
MVocabulary.fn.destructor.call(this);
|
|
|
|
},
|
|
|
|
"_createActions": function(actions) {
|
|
|
|
for (var i = 0; i < actions.length; ++i) {
|
|
|
|
var action = actions[i];
|
|
|
|
var actionVC = new Vocabulary();
|
|
|
|
actionVC.insert("type", new Uint64(action.type));
|
|
|
|
var supported = false;
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case 0: //this type of actions has only action itself, no additional arguments, what to do is desctibed in the view
|
|
|
|
actionVC.insert("action", new String(action.action));
|
|
|
|
supported = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (supported) {
|
|
|
|
this._actions.push(actionVC);
|
|
|
|
} else {
|
|
|
|
actionVC.destructor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-08-04 21:46:25 +00:00
|
|
|
"_getAllData": function() {
|
|
|
|
var vc = this.controller.data.clone();
|
|
|
|
|
|
|
|
vc.insert("hasPageLink", new Boolean(this.hasPageLink));
|
2018-11-28 06:54:14 +00:00
|
|
|
vc.insert("actions", this._actions.clone());
|
2018-08-04 21:46:25 +00:00
|
|
|
if (this.hasPageLink) {
|
|
|
|
vc.insert("pageLink", this._pageLink.clone());
|
|
|
|
}
|
|
|
|
|
2018-11-28 06:54:14 +00:00
|
|
|
|
2018-08-04 21:46:25 +00:00
|
|
|
return vc;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Pane;
|