Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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
nexedi
dream
Commits
734aabb1
Commit
734aabb1
authored
Jun 18, 2014
by
Romain Courteaud
🐙
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to create empty document.
parent
ae60f68f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
39 deletions
+108
-39
dream/platform/src2/dream/InputModule_viewAddDocumentDialog.html
...latform/src2/dream/InputModule_viewAddDocumentDialog.html
+3
-0
dream/platform/src2/dream/InputModule_viewAddDocumentDialog.js
.../platform/src2/dream/InputModule_viewAddDocumentDialog.js
+105
-39
No files found.
dream/platform/src2/dream/InputModule_viewAddDocumentDialog.html
View file @
734aabb1
...
...
@@ -11,6 +11,9 @@
<script
src=
"InputModule_viewAddDocumentDialog.js"
type=
"text/javascript"
></script>
</head>
<body>
<form
class=
"new_form"
>
<button
type=
"submit"
class=
"ui-btn ui-btn-b ui-btn-inline ui-icon-plus ui-btn-icon-right"
>
Empty
</button>
</form>
<form
class=
"import_form"
>
<input
id=
"dream_import"
type=
"file"
required=
""
name=
"dream_import"
>
...
...
dream/platform/src2/dream/InputModule_viewAddDocumentDialog.js
View file @
734aabb1
...
...
@@ -4,6 +4,106 @@
initGadgetMixin
)
{
"
use strict
"
;
function
createDocument
(
gadget
,
name
)
{
var
now
=
new
Date
();
// Create jIO document
return
gadget
.
aq_post
({
title
:
name
,
type
:
"
Dream
"
,
format
:
"
application/json
"
,
modified
:
now
.
toUTCString
(),
date
:
now
.
getFullYear
()
+
"
-
"
+
(
now
.
getMonth
()
+
1
)
+
"
-
"
+
now
.
getDate
()
});
}
function
waitForImport
(
gadget
)
{
var
json_data
,
name
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
promiseEventListener
(
gadget
.
props
.
element
.
getElementsByClassName
(
"
import_form
"
)[
0
],
'
submit
'
,
false
);
})
.
push
(
function
(
evt
)
{
// Prevent double click
evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
true
;
var
file
=
evt
.
target
.
dream_import
.
files
[
0
];
name
=
file
.
name
;
return
promiseReadAsText
(
file
);
})
.
push
(
function
(
json
)
{
json_data
=
json
;
return
createDocument
(
gadget
,
name
);
})
.
push
(
function
(
jio_document
)
{
// Add JSON as attachment
return
gadget
.
aq_putAttachment
({
"
_id
"
:
jio_document
.
id
,
"
_attachment
"
:
"
body.json
"
,
"
_data
"
:
json_data
,
"
_mimetype
"
:
"
application/json
"
});
});
}
function
waitForNew
(
gadget
)
{
var
json_data
=
{
nodes
:
{},
edges
:
{},
preference
:
{},
general
:
{},
wip_part_spreadsheet
:
[[
"
Order ID
"
,
"
Due Date
"
,
"
Priority
"
,
"
Project Manager
"
,
"
Part
"
,
"
Part Type
"
,
"
Sequence
"
,
"
Processing Times
"
,
"
Prerequisites Parts
"
]],
shift_spreadsheet
:
[[
"
Day
"
,
"
Machines
"
,
// XXX more generic name ?
"
Start
"
,
"
End
"
]]
},
name
=
"
FromScratch
"
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
promiseEventListener
(
gadget
.
props
.
element
.
getElementsByClassName
(
"
new_form
"
)[
0
],
'
submit
'
,
false
);
})
.
push
(
function
(
evt
)
{
// Prevent double click
evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
true
;
return
createDocument
(
gadget
,
name
);
})
.
push
(
function
(
jio_document
)
{
// Add JSON as attachment
return
gadget
.
aq_putAttachment
({
"
_id
"
:
jio_document
.
id
,
"
_attachment
"
:
"
body.json
"
,
"
_data
"
:
JSON
.
stringify
(
json_data
),
"
_mimetype
"
:
"
application/json
"
});
});
}
var
gadget_klass
=
rJS
(
window
);
initGadgetMixin
(
gadget_klass
);
gadget_klass
...
...
@@ -20,48 +120,14 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
startService
"
,
function
()
{
var
gadget
=
this
,
json_data
,
name
;
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
promiseEventListener
(
gadget
.
props
.
element
.
getElementsByClassName
(
"
import_form
"
)[
0
],
'
submit
'
,
false
);
})
.
push
(
function
(
evt
)
{
// Prevent double click
gadget
.
props
.
element
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
true
;
var
file
=
evt
.
target
.
dream_import
.
files
[
0
];
name
=
file
.
name
;
return
promiseReadAsText
(
file
);
})
.
push
(
function
(
json
)
{
var
now
=
new
Date
();
json_data
=
json
;
// Create jIO document
return
gadget
.
aq_post
({
title
:
name
,
type
:
"
Dream
"
,
format
:
"
application/json
"
,
modified
:
now
.
toUTCString
(),
date
:
now
.
getFullYear
()
+
"
-
"
+
(
now
.
getMonth
()
+
1
)
+
"
-
"
+
now
.
getDate
()
});
})
.
push
(
function
(
jio_document
)
{
// Add JSON as attachment
return
gadget
.
aq_putAttachment
({
"
_id
"
:
jio_document
.
id
,
"
_attachment
"
:
"
body.json
"
,
"
_data
"
:
json_data
,
"
_mimetype
"
:
"
application/json
"
});
return
RSVP
.
any
([
waitForImport
(
gadget
),
waitForNew
(
gadget
)
]);
})
.
push
(
function
(
result
)
{
return
gadget
.
whoWantToDisplayThisDocument
(
result
.
id
);
...
...
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