Commit 2591a526 authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs: add schema_editor

parent 7385e43c
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Schema Panel</title>
<!--
data-i18n=Editable
-->
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script id="panel-template-header" type="text/x-handlebars-template">
<div data-role="header" class="ui-bar-inherit">
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">
<div class="ui-controlgroup-controls">
<button data-i18n="Close" class="ui-btn ui-btn-icon-notext ui-icon-delete">Close</button>
</div>
</div>
</div>
</script>
<script id="panel-template-body" type="text/x-handlebars-template">
<div class="ui-content">
<form class="dialog_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-action ui-btn-icon-right ui-screen-hidden">Submit</button>
<div data-gadget-url="gadget_erp5_searchfield.html"
data-gadget-scope="erp5_searchfield"
data-gadget-sandbox="public"></div>
</form>
<ul data-role="listview" class="ui-listview" data-enhanced="true"></ul>
<dl></dl>
</div>
</script>
<script id="panel-template-body-list" type="text/x-handlebars-template">
<li class="ui-first-child"><a href="{{document_list_href}}" class="ui-btn ui-btn-icon-left ui-icon-search" data-i18n="Schemas" accesskey="s">Schemas</a></li>
<li><a href="{{sync_href}}" class="ui-btn ui-btn-icon-left ui-icon-refresh" data-i18n="Synchronize">Synchronize</a></li>
<li class="ui-last-child"><a href="{{storage_href}}" class="ui-btn ui-btn-icon-left ui-icon-dropbox" data-i18n="Storages">Storages</a></li>
<li class="ui-last-child"><a href="{{multi_upload_href}}" class="ui-btn ui-btn-icon-left ui-icon-upload" data-i18n="Upload">Upload</a></li>
</script>
<script id="panel-template-body-desktop" type="text/x-handlebars-template">
<dt class="ui-content-title ui-body-c ui-btn ui-btn-icon-left ui-icon-eye" data-i18n="Views">Views</dt>
{{#each view_list}}
<dd data-role="listview" data-theme="c" data-inset="true" class="document-listview">
<a data-i18n="{{title}}" class="ui-body-inherit" href="{{href}}">{{title}}</a>
</dd>
{{/each}}
<dt class="ui-content-title ui-body-c ui-btn ui-btn-icon-left ui-icon-cogs" data-i18n="Decisions">Decisions</dt>
{{#each workflow_list}}
<dd data-role="listview" data-theme="c" data-inset="true" class="document-listview">
<a data-i18n="{{title}}" class="ui-body-inherit" href="{{href}}">{{title}}</a>
</dd>
{{/each}}
</script>
<!-- custom script -->
<script src="gadget_erp5_ojs_schema_panel.js" type="text/javascript"></script>
</head>
<body>
<div class="jqm-navmenu-panel"></div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>OfficeJS Schema Router Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_router.js" type="text/javascript"></script>
</head>
<body>
<script data-renderjs-configuration="portal_type" type="text/x-renderjs-configuration">Json Schema</script>
<script data-renderjs-configuration="upload_content_type" type="text/x-renderjs-configuration">application/json</script>
<script data-renderjs-configuration="document_title" type="text/x-renderjs-configuration">Schema</script>
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Schemas</script>
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">json_schema_module</script>
<script data-renderjs-configuration="erp5_attachment_synchro" type="text/x-renderjs-configuration">/{+id}/Base_downloadWithCors</script>
<!--<script data-renderjs-configuration="dropbox_app_key" type="text/x-renderjs-configuration">er734e4262pczhh</script>-->
<div data-gadget-url="gadget_erp5_router.html" data-gadget-scope="erp5_router"></div>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Jio Schema Document List</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_schema_document_list.js"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getSetting", "getSetting")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, date, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("modification_date")) {
date = new Date(result.data.rows[i].value.modification_date);
result.data.rows[i].value.modification_date = {
field_gadget_param: {
allow_empty_time: 0,
ampm_time_style: 0,
css_class: "date_field",
date_only: 0,
description: "The Date",
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": date.toUTCString(),
key: "modification_date",
required: 0,
timezone_style: 0,
title: "Modification Date",
type: "DateTimeField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
return result;
});
})
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
.declareMethod("render", function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_list'),
gadget.getSetting("portal_type")
]);
})
.push(function (result) {
var column_list = [
['title', 'Title'],
['reference', 'Reference'],
['language', 'Language'],
['description', 'Description'],
['version', 'Version'],
['modification_date', 'Modification Date']
];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%22" +
result[1] + "%22",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [['modification_date', 'descending']],
"title": "Schemas",
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: "index", options: {"page": "ojs_multi_upload"}}),
gadget.getSetting('document_title_plural')
]);
})
.push(function (result) {
return gadget.updateHeader({
page_title: result[1],
filter_action: true,
add_url: result[0]
});
});
});
}(window, rJS, RSVP));
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Jio Schema View</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="gadget_officejs_jio_json_schema_view.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP, jIO, URL,
promiseEventListener, document*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, jIO, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this;
return gadget.changeState({
jio_key: options.jio_key,
doc: options.doc
});
})
.onEvent('submit', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (content) {
var list = [],
blob;
if (content.data_file_upload) {
blob = jIO.util.dataURItoBlob(content.data_file_upload.url);
content.title = content.data_file_upload.file_name;
delete content.data_file_upload;
list = [
gadget.updateDocument(content),
gadget.jio_putAttachment(gadget.state.jio_key, 'data', blob)
];
} else if (content.data) {
blob = new Blob([content.data]);
delete content.data;
list = [
gadget.updateDocument(content),
gadget.jio_putAttachment(gadget.state.jio_key, 'data', blob)
];
} else {
list = [gadget.updateDocument(content)];
}
return RSVP.all(list);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
}, function (error) {
if (error.target && error.target.error.name === 'NotReadableError') {
return gadget.notifySubmitted({message: error.target.error.message, status: 'fail'});
}
throw error;
}).push(function () {
return gadget.redirect({
command: 'reload'
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.onStateChange(function () {
var gadget = this;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.jio_getAttachment(gadget.state.jio_key, 'data', {format: "json"})
]);
})
.push(function (result) {
return result[0].render({
erp5_document: {
"_embedded": {
"_view": {
"my_title": {
"description": "",
"title": "Title",
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_file": {
"description": "",
"title": "Upload and rewrite this document",
"default": "",
"css_class": "",
"required": 0,
"editable": 1,
"key": "data_file_upload",
"hidden": 0,
"accept": "application/json",
"type": "FileField"
},
"my_content": {
"default": result[1],
"css_class": "",
"required": 0,
"editable": 1,
"key": "data",
"hidden": 0,
"type": "GadgetField",
"renderjs_extra": '{"name": "data"}',
"url": "jsonform.gadget.html",
"sandbox": "public"
}
}
},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_file"]]
], [
"bottom",
[["my_content"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
save_action: true,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2]
});
});
});
}(window, jIO, rJS, RSVP));
erp5_web_renderjs_ui
erp5_code_mirror
erp5_json_form
erp5_multimedia
erp5_notebook
erp5_smart_assistant
\ No newline at end of file
......@@ -7,6 +7,8 @@ image_module/officejs_todomvc_*
image_module/wallsearch_icon_svg
web_page_module/dhtmlx_gantt_*
web_page_module/fb_sdk_js
web_page_module/gadget_erp5_ojs_*
web_page_module/gadget_erp5_page_ojs_*
web_page_module/gadget_field_*
web_page_module/gadget_officejs_*
web_page_module/jio_*
......@@ -32,6 +34,8 @@ web_site_module/officejs_notebook
web_site_module/officejs_notebook/**
web_site_module/officejs_pdf_viewer
web_site_module/officejs_pdf_viewer/**
web_site_module/officejs_schema
web_site_module/officejs_schema/**
web_site_module/officejs_svg_editor
web_site_module/officejs_svg_editor/**
web_site_module/officejs_text_editor
......
......@@ -7,6 +7,8 @@ image_module/officejs_todomvc_*
image_module/wallsearch_icon_svg
web_page_module/dhtmlx_gantt_*
web_page_module/fb_sdk_js
web_page_module/gadget_erp5_ojs_*
web_page_module/gadget_erp5_page_ojs_*
web_page_module/gadget_field_*
web_site_module/officejs_media_player
web_page_module/gadget_officejs_*
......@@ -32,6 +34,8 @@ web_site_module/officejs_notebook
web_site_module/officejs_notebook/**
web_site_module/officejs_pdf_viewer
web_site_module/officejs_pdf_viewer/**
web_site_module/officejs_schema
web_site_module/officejs_schema/**
web_site_module/officejs_svg_editor
web_site_module/officejs_svg_editor/**
web_site_module/officejs_text_editor
......
......@@ -7,6 +7,8 @@ image_module/officejs_todomvc_*
image_module/wallsearch_icon_svg
web_page_module/dhtmlx_gantt_*
web_page_module/fb_sdk_js
web_page_module/gadget_erp5_ojs_*
web_page_module/gadget_erp5_page_ojs_*
web_page_module/gadget_field_*
web_page_module/gadget_officejs_*
web_page_module/jio_*
......@@ -33,6 +35,8 @@ web_site_module/officejs_notebook
web_site_module/officejs_notebook/**
web_site_module/officejs_pdf_viewer
web_site_module/officejs_pdf_viewer/**
web_site_module/officejs_schema
web_site_module/officejs_schema/**
web_site_module/officejs_smart_assistant
web_site_module/officejs_smart_assistant/**
web_site_module/officejs_svg_editor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment