Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
b7f4f3a2
Commit
b7f4f3a2
authored
Feb 13, 2015
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_renderjs_ui: display time in datetimefield
parent
0f29e32b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
19 deletions
+86
-19
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
...tal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
+3
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_js.xml
...Item/web_page_module/rjs_gadget_erp5_datetimefield_js.xml
+83
-19
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
View file @
b7f4f3a2
...
@@ -162,6 +162,9 @@ def renderField(field, meta_type=None):\n
...
@@ -162,6 +162,9 @@ def renderField(field, meta_type=None):\n
"date_only": field.get_value("date_only"),\n
"date_only": field.get_value("date_only"),\n
"ampm_time_style": field.get_value("ampm_time_style"),\n
"ampm_time_style": field.get_value("ampm_time_style"),\n
"timezone_style": field.get_value("timezone_style"),\n
"timezone_style": field.get_value("timezone_style"),\n
"allow_empty_time": field.get_value(\'allow_empty_time\'),\n
"hide_day": field.get_value(\'hide_day\'),\n
"hidden_day_is_last_day": field.get_value(\'hidden_day_is_last_day\'),\n
}\n
}\n
date_value = field.get_value("default")\n
date_value = field.get_value("default")\n
if same_type(date_value, DateTime()):\n
if same_type(date_value, DateTime()):\n
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_js.xml
View file @
b7f4f3a2
...
@@ -99,9 +99,11 @@
...
@@ -99,9 +99,11 @@
</item>
</item>
<item>
<item>
<key>
<string>
text_content
</string>
</key>
<key>
<string>
text_content
</string>
</key>
<value>
<string>
/*global window, rJS */\n
<value>
<string
encoding=
"cdata"
>
<![CDATA[
/*global window, rJS, RSVP */\n
/*jslint indent: 2, maxerr: 3 */\n
/*jslint indent: 2, maxerr: 3 */\n
(function (window, rJS) {\n
(function (window, rJS
, RSVP
) {\n
"use strict";\n
"use strict";\n
\n
\n
rJS(window)\n
rJS(window)\n
...
@@ -112,19 +114,28 @@
...
@@ -112,19 +114,28 @@
gadget.props = {};\n
gadget.props = {};\n
});\n
});\n
})\n
})\n
.declareAcquiredMethod("notifyInvalid", "notifyInvalid")\n
.declareMethod(\'render\', function (options) {\n
.declareMethod(\'render\', function (options) {\n
var input = this.element.querySelector(\'input\'),\n
var input = this.element.querySelector(\'input\'),\n
date,\n
time = "",\n
field_json = options.field_json || {},\n
field_json = options.field_json || {},\n
value = field_json.value || field_json.default || "";\n
value = field_json.value || field_json.default || "";\n
this.props.field_json = field_json;\n
this.props.field_json = field_json;\n
\n
//Change type to datetime/datetime local if configured in the field\n
if (value !== "") {\n
if (value !== "") {\n
value = new Date(value).toISOString();\n
// XXX Ensure the timezone is not lost\n
// XXX Ensure the timezone is not lost\n
value = new Date(value).toISOString().substring(0, 10);\n
date = value.substring(0, 10);\n
if (field_json.date_only === 0) {\n
time = value.substring(10, 19);\n
input.setAttribute("type", "datetime-local");\n
}\n
}\n
}\n
// XXX Change type to datetime/datetime local if configured in the field\n
input.setAttribute(\n
input.setAttribute(\n
\'value\',\n
\'value\',\n
valu
e\n
date + tim
e\n
);\n
);\n
input.setAttribute(\'name\', field_json.key);\n
input.setAttribute(\'name\', field_json.key);\n
input.setAttribute(\'title\', field_json.title);\n
input.setAttribute(\'title\', field_json.title);\n
...
@@ -138,26 +149,79 @@
...
@@ -138,26 +149,79 @@
\n
\n
}\n
}\n
})\n
})\n
\n
.declareMethod(\'getDateTime\', function () {\n
.declareMethod(\'getContent\', function () {\n
var input = this.element.querySelector(\'input\'),\n
var input = this.element.querySelector(\'input\'),\n
result = {},\n
result = {},\n
year,\n
month,\n
field_json = this.props.field_json,\n
date,\n
hour,\n
minute,\n
value = input.value;\n
value = input.value;\n
if (value) {\n
if (value) {\n
value = new Date(value);\n
value = new Date(value);\n
year = value.getFullYear();\n
month = value.getMonth() + 1;\n
if (field_json.hide_day === 1) {\n
date = 1;\n
} else {\n
date = value.getDate();\n
}\n
if (field_json.date_only === 0) {\n
if (field_json.allow_empty_time === 1) {\n
hour = 0;\n
minute = 0;\n
} else {\n
hour = value.getUTCHours();\n
minute = value.getMinutes();\n
}\n
if (field_json.ampm_time_style === 1) {\n
if (hour >
12) {\n
result[field_json.subfield_ampm_key] = "pm";\n
hour -= 12;\n
} else {\n
result[field_json.subfield_ampm_key] = "am";\n
}\n
}\n
result[field_json.subfield_hour_key] = hour;\n
result[field_json.subfield_minute_key] = minute;\n
}\n
if (field_json.hidden_day_is_last_day === 1) {\n
if (month === 12) {\n
year += 1;\n
month = 1;\n
} else {\n
month += 1;\n
}\n
}\n
result[field_json.subfield_year_key] = year;\n
result[field_json.subfield_month_key] = month;\n
result[field_json.subfield_day_key] = date;\n
\n
// XXX Ensure the timezone is not lost\n
// XXX Ensure the timezone is not lost\n
result[this.props.field_json.subfield_year_key] = value.getFullYear();\n
// result[field_json.subfield_timezone_key] = value.getDate();\n
result[this.props.field_json.subfield_month_key] = value.getMonth() + 1;\n
result[this.props.field_json.subfield_day_key] = value.getDate();\n
// result[this.props.subfield_hour_key] = value.getDate();\n
// result[this.props.subfield_minute_key] = value.getDate();\n
// result[this.props.subfield_ampm_key] = value.getDate();\n
// result[this.props.subfield_timezone_key] = value.getDate();\n
}\n
}\n
return result;\n
return result;\n
})\n
.declareMethod(\'checkValidity\', function () {\n
//xxx check time range (start_datetime, end_datetime)\n
return true;\n
})\n
.declareMethod(\'getContent\', function () {\n
var gadget = this;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.getDateTime();\n
})\n
.push(function (result) {\n
return result;\n
});\n
});\n
});\n
\n
\n
}(window, rJS));
</string>
</value>
}(window, rJS, RSVP));
]]>
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
title
</string>
</key>
<key>
<string>
title
</string>
</key>
...
@@ -278,7 +342,7 @@
...
@@ -278,7 +342,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
romain
</string>
</value>
<value>
<string>
xiaowu
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
@@ -292,7 +356,7 @@
...
@@ -292,7 +356,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
940.
52111.6434.35515
</string>
</value>
<value>
<string>
940.
62359.8275.23142
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -310,8 +374,8 @@
...
@@ -310,8 +374,8 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1423
235934.98
</float>
<float>
1423
850641.53
</float>
<string>
GMT
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
</object>
</object>
...
...
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