Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
e8fec70b
Commit
e8fec70b
authored
Jul 13, 2015
by
Vivek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
96288880
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
177 additions
and
59 deletions
+177
-59
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/demo_interface1_html.xml
...PathTemplateItem/web_page_module/demo_interface1_html.xml
+1
-1
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_html.xml
...emplateItem/web_page_module/gadget_interfacedemo_html.xml
+2
-3
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_js.xml
...hTemplateItem/web_page_module/gadget_interfacedemo_js.xml
+34
-13
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/rjs_gadget_interfaces_js.xml
...TemplateItem/web_page_module/rjs_gadget_interfaces_js.xml
+140
-42
No files found.
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/demo_interface1_html.xml
View file @
e8fec70b
...
...
@@ -288,7 +288,7 @@
</tuple>
<state>
<tuple>
<float>
1436
446773.66
</float>
<float>
1436
545182.61
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_html.xml
View file @
e8fec70b
...
...
@@ -119,7 +119,6 @@
<script
src=
"renderjs.js"
type=
"text/javascript"
></script>
\n
<script
src=
"handlebars.js"
type=
"text/javascript"
></script>
\n
<script
src=
"jquery.js"
type=
"text/javascript"
></script>
\n
<script
src=
"gadget_interfaces.js"
type=
"text/javascript"
></script>
\n
\n
<!-- custom script -->
\n
<script
src=
"gadget_interfacedemo.js"
type=
"text/javascript"
></script>
\n
...
...
@@ -288,7 +287,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.1
7439.65022.59426
</string>
</value>
<value>
<string>
944.1
8548.40475.62395
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -306,7 +305,7 @@
</tuple>
<state>
<tuple>
<float>
1436
452642.01
</float>
<float>
1436
518406.8
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_js.xml
View file @
e8fec70b
...
...
@@ -104,6 +104,9 @@
(function (window, rJS, Handlebars, $, jQuery, RSVP) {\n
"use strict";\n
\n
var INTERFACE_GADGET_URL = "./gadget_interfaces.html",\n
INTERFACE_GADGET_SCOPE = "interface";\n
\n
rJS(window)\n
.ready(function (g) {\n
g.props = {};\n
...
...
@@ -123,20 +126,38 @@
})\n
\n
.declareMethod("method1", function (param1, param2) {\n
console.log("RJS IDemo JS: declareMethod: method1");\n
return;\n
})\n
.declareMethod("method2", function (param1) {\n
console.log("RJS IDemo JS: declareMethod: method2");\n
return;\n
})\n
.declareMethod("method3", function () {\n
return;\n
})\n
\n
.declareMethod("interfaceGadgetTest", function (gadget, interface_gadget, interface_list) {\n
var interface_name = interface_list[0];\n
return new RSVP.Queue()\n
.push(function () {\n
return interface_gadget.getInterfaceData(interface_name);\n
})\n
.push(function (interface_data) {\n
console.log("interface_data", interface_data);\n
return interface_gadget.verifyInterfaceImplementation(gadget, interface_name);\n
})\n
.push(function (verification_status) {\n
console.log("Verification:", verification_status);\n
});\n
})\n
\n
.declareMethod("render", function () {\n
var gadget = this;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.declareGadget(INTERFACE_GADGET_URL, {\n
scope: INTERFACE_GADGET_SCOPE,\n
element: gadget.__element\n
});\n
})\n
.push(function () {\n
return gadget.getInterfaceList();\n
})\n
...
...
@@ -154,15 +175,15 @@
gadget.props.content_element.innerHTML =\n
gadget.props.interface_list_template(parameter);\n
$(gadget.props.element).trigger("create");\n
return parameter.interface_item;\n
return RSVP.all([\n
gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE),\n
interface_list\n
]);\n
})\n
.push(function (interface_items) {\n
// testing getInterfaceData.\n
return gadget.getInterfaceData(interface_items[0].interface_name);\n
})\n
.push(function (interface_data) {\n
console.log("interface_data", interface_data);\n
console.log("getPath", gadget.getPath());\n
.push(function (interface_gadget_list) {\n
var interface_gadget = interface_gadget_list[0],\n
interface_list = interface_gadget_list[1];\n
return gadget.interfaceGadgetTest(gadget, interface_gadget, interface_list);\n
});\n
});\n
\n
...
...
@@ -301,7 +322,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.1
7453.1344.10683
</string>
</value>
<value>
<string>
944.1
8996.27011.18756
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -319,7 +340,7 @@
</tuple>
<state>
<tuple>
<float>
1436
453615.05
</float>
<float>
1436
545240.66
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/rjs_gadget_interfaces_js.xml
View file @
e8fec70b
...
...
@@ -151,25 +151,89 @@
(function (window, rJS, Handlebars, $, RSVP, loopEventListener, DOMParser) {\n
"use strict";\n
\n
function verifyInterfaceDe
claration (gadget
) {\n
return;
\n
function verifyInterfaceDe
finitiion (interface_name
) {\n
//to verify if interface definition follows the correct template.
\n
}\n
\n
function verifyAllMethodsDeclared (interface_methods, gadget_methods) {\n
return;\n
function verifyInterfaceDeclaration (interface_name, declared_interfaces) {\n
//to verify if gadget declares the interface.\n
return declared_interfaces.indexOf(interface_name) >
-1;\n
}\n
\n
function verifyAllMethodsDeclared (interface_methods, gadget_methods) {\n
//to verify if all the interface methods are declared by the gadget.\n
var gadget_methods_names = [],\n
interface_methods_names = [];\n
for (var i=0; i
<gadget_methods.length
;
i+=1)
{\n
gadget_methods_names.push(gadget_methods[i].name);\n
}\n
for
(var
j=
0;
j<interface_methods.length;
j+=1)
{\n
interface_methods_names.push(interface_methods[j].name);\n
}\n
for
(var
k=
0;
k<interface_methods_names.length;
k+=1)
{\n
if(gadget_methods_names.indexOf(interface_methods_names[k])
<
0)
{\n
return
false;\n
}\n
}\n
return
true;\n
}\n
\n
function
verifyAllMethodsSignature
(interface_methods,
gadget_methods)
{\n
//to
verify
if
all
the
declared
methods
match
the
signature
of
the
interface
methods.\n
var
interface_methods_dict =
{},\n
gadget_methods_dict =
{};\n
for(var
i=
0;
i<interface_methods.length;
i+=1)
{\n
interface_methods_dict[interface_methods[i].name]
=
interface_methods[i];\n
}\n
for(var
j=
0;
j<gadget_methods.length;
j+=1)
{\n
gadget_methods_dict[gadget_methods[j].name]
=
gadget_methods[j];\n
}\n
for(var
item
in
interface_methods_dict)
{\n
if(!verifyMethodSignature(interface_methods_dict[item],
gadget_methods_dict[item]))
{\n
return
false;\n
}\n
}\n
return
true;\n
}\n
\n
function
verifyMethodSignature
(interface_method,
gadget_method)
{\n
return;\n
//to
verify
if
two
methods
have
the
same
signature\n
var
max_arg_len =
interface_method.argument_list.length,\n
min_arg_len =
0;\n
if
(max_arg_len)
{\n
var
argument_list =
interface_method.argument_list;\n
for
(var
i=
0;
i<argument_list.length;
i+=1)
{\n
if
(argument_list[i].required)
{\n
min_arg_len
+=
1;\n
}\n
}\n
}\n
return
(gadget_method.arg_len
>
= min_arg_len
&&
gadget_method.arg_len
<
= max_arg_len);\n
}\n
\n
rJS(window)\n
.ready(function (g) {\n
g.props = {};\n
})\n
\n
.declareMethod("getDeclaredGadgetInterfaces", function (gadget) {\n
return RSVP.Queue()\n
.push(function() {\n
return gadget.getInterfaceList();\n
})\n
.push(function (declared_interfaces) {\n
return declared_interfaces;\n
});\n
})\n
\n
.declareMethod("getDeclaredGadgetMethods", function (gadget) {\n
return;\n
return RSVP.Queue()\n
.push(function() {\n
return gadget.getDeclaredMethodList();\n
})\n
.push(function (declared_methods) {\n
return declared_methods;\n
});\n
})\n
\n
.declareMethod("getInterfaceData", function (interface_name) {\n
...
...
@@ -190,41 +254,31 @@
method_len = dl_list.length - 1,\n
dt_count = 0, \n
dl_count = 1;\n
interface_data.name = doc.getElementsByTagName(\'h1\')[0].innerText;\n
interface_data.description = doc.getElementsByTagName(\'h3\')[0].innerText;\n
\n
for (var i=0; i<method_len; i+=1) {\n
var method = {\n
name: "",\n
description: "",\n
argument_list: []\n
};\n
method.name = dt_list[dt_count].innerText;\n
method.description = dd_list[dt_count].innerText;\n
var argument_len = dl_list[dl_count].getElementsByTagName(\'dt\').length;\n
interface_data.name = doc.getElementsByTagName(\'h1\')[0].innerText;\n
interface_data.description = doc.getElementsByTagName(\'h3\')[0].innerText;\n
for (var i=0; i
<method_len
;
i+=1)
{\n
var
method =
{\n
name:
dt_list[dt_count].innerText,\n
description:
dd_list[dt_count].innerText,\n
argument_list:
[]\n
},\n
argument_len =
dl_list[dl_count].getElementsByTagName(\'dt\').length;\n
dt_count
+=
1;\n
dl_count
+=
1;\n
for
(var
j=
0;
j<argument_len;
j+=1)
{\n
var
argument_item =
{\n
name:
dt_list[dt_count].innerText,\n
description:
dd_list[dt_count].innerText,\n
required:
dt_list[dt_count].getAttribute("class")
===
"optional"
?
false:true,\n
type:
dt_list[dt_count].getAttribute("type")\n
};\n
dt_count
+=
1;\n
dl_count += 1;\n
for (var j=0; j<argument_len; j+=1) {\n
var argument_item = {\n
name: "",\n
description: "",\n
required: true,\n
type: ""\n
};\n
if(dt_list[dt_count].getAttribute("class") == "optional") {\n
argument_item.required = false;\n
}\n
argument_item.type = dt_list[dt_count].getAttribute("type");\n
argument_item.name = dt_list[dt_count].innerText;\n
argument_item.description = dd_list[dt_count].innerText;\n
dt_count += 1;\n
method.argument_list.push(argument_item);\n
}\n
interface_data.methods.push(method);\n
method.argument_list.push(argument_item);\n
}\n
return interface_data;\n
interface_data.methods.push(method);\n
}\n
return
interface_data;\n
});\n
\n
})\n
\n
.declareMethod("getDefinedInterfaceMethods",
function
(interface_name)
{\n
...
...
@@ -233,9 +287,53 @@
return
interface_data.methods;\n
});\n
})\n
\n
\n
.declareMethod("verifyInterfaceImplementation",
function
(gadget,
interface_name)
{\n
return;\n
var
interface_gadget =
this;\n
return
RSVP.Queue()\n
.push(function
()
{\n
return
interface_gadget.getDeclaredGadgetInterfaces(gadget);\n
})\n
.push(function
(declared_interfaces)
{\n
return
verifyInterfaceDeclaration(interface_name,
declared_interfaces);\n
})\n
.push(function
(verified)
{\n
if
(!verified)
{\n
throw
new
Error("Interface
not
declared.");\n
}\n
return
RSVP.all([\n
interface_gadget.getDefinedInterfaceMethods(interface_name),\n
interface_gadget.getDeclaredGadgetMethods(gadget)\n
]);\n
})\n
.push(function(methods_list)
{\n
return
verifyAllMethodsDeclared(methods_list[0],
methods_list[1]);\n
})\n
.push(function
(verified)
{\n
if
(!verified)
{\n
throw
new
Error("All
methods
are
not
declared.");\n
}\n
return
RSVP.all([\n
interface_gadget.getDefinedInterfaceMethods(interface_name),\n
interface_gadget.getDeclaredGadgetMethods(gadget)\n
]);\n
})\n
.push(function(methods_list)
{\n
return
verifyAllMethodsSignature(methods_list[0],
methods_list[1]);\n
})\n
.push(function
(verified)
{\n
if
(!verified)
{\n
throw
new
Error("All
methods
signature
do
not
match.");\n
}\n
})\n
.push
(function()
{\n
console.log("Verified
:
Success");\n
return
true;\n
},
function(error_message)
{\n
console.log("Verified
:
Failure",
error_message);\n
return
false;\n
});\n
\n
});\n
\n
}(window,
rJS,
Handlebars,
jQuery,
RSVP,
loopEventListener,
DOMParser));
...
...
@@ -375,7 +473,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.1
7466.54680.49015
</string>
</value>
<value>
<string>
944.1
8970.20251.32904
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -393,7 +491,7 @@
</tuple>
<state>
<tuple>
<float>
1436
453641.0
</float>
<float>
1436
544696.2
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment