an ability to create panes actions, player frontend draft
This commit is contained in:
parent
2d2ad3085f
commit
b2ddc804c7
16 changed files with 304 additions and 28 deletions
|
@ -6,3 +6,4 @@ add_jslib(wModel/proxy/vocabulary.js lib/wModel/proxy/vocabulary ${MAGNUS_DIR} n
|
|||
add_jslib(wModel/proxy/catalogue.js lib/wModel/proxy/catalogue ${MAGNUS_DIR} node)
|
||||
|
||||
configure_file(pane.js pane.js)
|
||||
configure_file(panesList.js panesList.js)
|
||||
|
|
|
@ -4,12 +4,18 @@ var MVocabulary = require("./vocabulary");
|
|||
|
||||
var Address = require("../../wType/address");
|
||||
var Boolean = require("../../wType/boolean");
|
||||
var Uint64 = require("../../wType/uint64");
|
||||
var String = require("../../wType/string");
|
||||
var Vocabulary = require("../../wType/vocabulary");
|
||||
var Vector = require("../../wType/vector");
|
||||
|
||||
var Pane = MVocabulary.inherit({
|
||||
"className": "Pane",
|
||||
"constructor": function(address, controllerAddress, socket) {
|
||||
"constructor": function(address, controllerAddress, socket, actions) {
|
||||
MVocabulary.fn.constructor.call(this, address, controllerAddress, socket);
|
||||
|
||||
this._actions = new Vector();
|
||||
this._createActions(actions || []);
|
||||
if (this.constructor.pageAddress) {
|
||||
this.hasPageLink = true;
|
||||
|
||||
|
@ -17,14 +23,45 @@ var Pane = MVocabulary.inherit({
|
|||
this._pageLink = this.constructor.pageAddress["+"](new Address([id.toString()]));
|
||||
}
|
||||
},
|
||||
"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();
|
||||
}
|
||||
}
|
||||
},
|
||||
"_getAllData": function() {
|
||||
var vc = this.controller.data.clone();
|
||||
|
||||
vc.insert("hasPageLink", new Boolean(this.hasPageLink));
|
||||
vc.insert("actions", this._actions.clone());
|
||||
if (this.hasPageLink) {
|
||||
vc.insert("pageLink", this._pageLink.clone());
|
||||
}
|
||||
|
||||
|
||||
return vc;
|
||||
}
|
||||
});
|
||||
|
|
66
magnus/lib/wModel/proxy/panesList.js
Normal file
66
magnus/lib/wModel/proxy/panesList.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
"use strict";
|
||||
|
||||
var Vocabulary = require("../../wType/vocabulary");
|
||||
var Uint64 = require("../../wType/uint64");
|
||||
var String = require("../../wType/string");
|
||||
var Vector = require("../../wType/vector");
|
||||
|
||||
var Catalogue = require("./catalogue");
|
||||
|
||||
var PanesList = Catalogue.inherit({
|
||||
"className": "PanesList",
|
||||
"constructor": function(address, ctrlAddr, ctrlOpts, socket, actions) {
|
||||
Catalogue.fn.constructor.call(this, address, ctrlAddr, ctrlOpts, socket);
|
||||
|
||||
this._actions = new Vector();
|
||||
this._createActions(actions || []);
|
||||
},
|
||||
"destructor": function() {
|
||||
this._actions.destructor();
|
||||
|
||||
Catalogue.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();
|
||||
}
|
||||
}
|
||||
},
|
||||
"_h_get": function(ev) {
|
||||
if (this.ready) {
|
||||
var vc = new Vocabulary();
|
||||
|
||||
vc.insert("data", this._getAllData());
|
||||
vc.insert("actions", this._actions.clone());
|
||||
this.response(vc, "get", ev);
|
||||
} else {
|
||||
this._waitingEvents.push(ev.clone());
|
||||
}
|
||||
},
|
||||
"_onRemoteData": function() {
|
||||
this.setReady(true);
|
||||
|
||||
var vc = new Vocabulary();
|
||||
vc.insert("data", this._getAllData());
|
||||
vc.insert("actions", this._actions.clone());
|
||||
|
||||
this.broadcast(vc, "get")
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = PanesList;
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var TempPage = require("./tempPage");
|
||||
var String = require("../lib/wModel/string");
|
||||
var ProxyCatModel = require("../lib/wModel/proxy/catalogue");
|
||||
var PanesList = require("../lib/wModel/proxy/panesList");
|
||||
var PaneModel = require("../lib/wModel/proxy/pane");
|
||||
var Image = require("../lib/wModel/image");
|
||||
var Model = require("../lib/wModel/model");
|
||||
|
@ -41,16 +41,19 @@ var AlbumPage = TempPage.inherit({
|
|||
var spacer = new Model(this._address["+"](new Address(["spacer"])));
|
||||
this.addItem(spacer, 0, 2, 2, 1);
|
||||
|
||||
this._songs = new ProxyCatModel(
|
||||
this._songs = new PanesList(
|
||||
this._address["+"](new Address(["songs"])),
|
||||
new Address(["songs"]),
|
||||
{
|
||||
sorting: {ascending: true, field: "name"},
|
||||
filter: {album: id.clone()}
|
||||
},
|
||||
proxySocket
|
||||
proxySocket,
|
||||
[{
|
||||
type: 0,
|
||||
action: "play"
|
||||
}]
|
||||
);
|
||||
this._songs.className = "PanesList";
|
||||
var PaneClass = PaneModel.Songs;
|
||||
this._songs.setChildrenClass(PaneClass);
|
||||
this.addItem(this._songs, 2, 0, 1, 3, TempPage.Aligment.CenterTop);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var TempPage = require("./tempPage");
|
||||
var String = require("../lib/wModel/string");
|
||||
var ProxyCatModel = require("../lib/wModel/proxy/catalogue");
|
||||
var PanesList = require("../lib/wModel/proxy/panesList");
|
||||
var PaneModel = require("../lib/wModel/proxy/pane");
|
||||
|
||||
var VCController = require("../lib/wController/vocabulary");
|
||||
|
@ -22,7 +22,7 @@ var ArtistPage = TempPage.inherit({
|
|||
header.addProperty("fontFamily", "casualFont");
|
||||
this.addItem(header, 0, 0, 1, 1, TempPage.Aligment.CenterTop);
|
||||
|
||||
this._albums = new ProxyCatModel(
|
||||
this._albums = new PanesList(
|
||||
this._address["+"](new Address(["albums"])),
|
||||
new Address(["albums"]),
|
||||
{
|
||||
|
@ -36,16 +36,19 @@ var ArtistPage = TempPage.inherit({
|
|||
this._albums.setChildrenClass(PaneClass);
|
||||
this.addItem(this._albums, 1, 0, 1, 1, TempPage.Aligment.CenterTop);
|
||||
|
||||
this._songs = new ProxyCatModel(
|
||||
this._songs = new PanesList(
|
||||
this._address["+"](new Address(["songs"])),
|
||||
new Address(["songs"]),
|
||||
{
|
||||
sorting: {ascending: true, field: "name"},
|
||||
filter: {artist: id.clone()}
|
||||
},
|
||||
proxySocket
|
||||
proxySocket,
|
||||
[{
|
||||
type: 0,
|
||||
action: "play"
|
||||
}]
|
||||
);
|
||||
this._songs.className = "PanesList";
|
||||
var PaneClass = PaneModel.Songs;
|
||||
this._songs.setChildrenClass(PaneClass);
|
||||
this.addItem(this._songs, 2, 0, 1, 1, TempPage.Aligment.CenterTop);
|
||||
|
|
|
@ -2,42 +2,45 @@
|
|||
|
||||
var Page = require("../lib/wModel/page");
|
||||
var String = require("../lib/wModel/string");
|
||||
var ProxyCatModel = require("../lib/wModel/proxy/catalogue");
|
||||
var PanesList = require("../lib/wModel/proxy/panesList");
|
||||
var PaneModel = require("../lib/wModel/proxy/pane");
|
||||
|
||||
var Address = require("../lib/wType/address");
|
||||
var Uint64 = require("../lib/wType/uint64");
|
||||
var Vocabulary = require("../lib/wType/vocabulary");
|
||||
|
||||
var Handler = require("../lib/wDispatcher/handler");
|
||||
|
||||
var List = Page.inherit({
|
||||
"className": "ListPage",
|
||||
"constructor": function(address, name, remoteAddress, socket, ChildClass) {
|
||||
"constructor": function(address, name, remoteAddress, socket, ChildClass, listOptions, paneActions) {
|
||||
Page.fn.constructor.call(this, address, name);
|
||||
|
||||
this._proxySocket = socket;
|
||||
this._ChildClass = ChildClass;
|
||||
this._listOptions = listOptions || new Vocabulary()
|
||||
|
||||
var header = new String(this._address["+"](new Address(["header"])), name);
|
||||
header.addProperty("fontFamily", "casualFont");
|
||||
this.addItem(header, 0, 0, 1, 1, Page.Aligment.CenterTop);
|
||||
|
||||
this._list = new ProxyCatModel(
|
||||
this._list = new PanesList(
|
||||
this._address["+"](new Address(["list"])),
|
||||
remoteAddress,
|
||||
{
|
||||
sorting: {ascending: true, field: "name"}
|
||||
},
|
||||
socket
|
||||
socket,
|
||||
paneActions
|
||||
);
|
||||
this._list.className = "PanesList";
|
||||
var PaneClass = PaneModel[name];
|
||||
if (!PaneClass) {
|
||||
PaneClass = PaneModel.inherit({});
|
||||
PaneClass.pageAddress = address;
|
||||
PaneModel[name] = PaneClass;
|
||||
}
|
||||
this._list.setChildrenClass(PaneClass);
|
||||
this.addItem(this._list, 1, 0, 1, 1, Page.Aligment.CenterTop);
|
||||
this.addItem(this._list, 1, 0, 1, 1, Page.Aligment.CenterTop, new Uint64(List.getModelTypeId(this._list)), listOptions);
|
||||
|
||||
this._reporterHandler = new Handler(this._address["+"](new Address(["subscribeMember"])), this, this._h_subscribeMember);
|
||||
},
|
||||
|
|
|
@ -7,6 +7,7 @@ var PanesList = require("../lib/wModel/panesList");
|
|||
var Address = require("../lib/wType/address");
|
||||
var Vocabulary = require("../lib/wType/vocabulary");
|
||||
var Boolean = require("../lib/wType/boolean");
|
||||
var Uint64 = require("../lib/wType/uint64");
|
||||
|
||||
var Link = require("../lib/wModel/link");
|
||||
|
||||
|
@ -135,12 +136,19 @@ var MusicPage = Page.inherit({
|
|||
this._albumsLink.label.addProperty("color", "primaryFontColor");
|
||||
this._albumsLink.addProperty("backgroundColor", "primaryColor");
|
||||
|
||||
var lOpts = new Vocabulary();
|
||||
lOpts.insert("nestWidth", new Uint64(300));
|
||||
this._songs = new List(
|
||||
this._addresses.songs.local.clone(),
|
||||
"Songs",
|
||||
this._addresses.songs.remote.clone(),
|
||||
socket,
|
||||
Song
|
||||
Song,
|
||||
lOpts,
|
||||
[{
|
||||
type: 0,
|
||||
action: "play"
|
||||
}]
|
||||
);
|
||||
this._songsLink = new Link(this._address["+"](new Address(["songsLink"])), "Songs", this._addresses.songs.local.clone());
|
||||
this._songsLink.label.addProperty("fontSize", "largeFontSize");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue