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
Labels
Merge Requests
138
Merge Requests
138
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
b6b09964
Commit
b6b09964
authored
Jul 24, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: schema editor: add fetch and upload field on upload page
parent
1c2f03a3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
10 deletions
+78
-10
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_erp5_page_ojs_zip_upload.js.js
...tem/web_page_module/gadget_erp5_page_ojs_zip_upload.js.js
+78
-10
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_erp5_page_ojs_zip_upload.js.js
View file @
b6b09964
/*global window, rJS, RSVP, loopEventListener,
/*global window, rJS, RSVP, loopEventListener,
jIO, document */
jIO, document
, URL
*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
jIO
,
RSVP
)
{
(
function
(
window
,
rJS
,
jIO
,
RSVP
)
{
"
use strict
"
;
"
use strict
"
;
...
@@ -10,6 +10,17 @@
...
@@ -10,6 +10,17 @@
Text
:
'
application/x-asc-text
'
Text
:
'
application/x-asc-text
'
};
};
function
displayError
(
g
,
text
)
{
return
g
.
notifySubmitted
({
message
:
text
,
status
:
'
fail
'
})
.
push
(
function
()
{
// return undefined for fail detection
return
;
});
}
function
endsWith
(
str
,
suffix
)
{
function
endsWith
(
str
,
suffix
)
{
return
str
.
indexOf
(
suffix
,
str
.
length
-
suffix
.
length
)
!==
-
1
;
return
str
.
indexOf
(
suffix
,
str
.
length
-
suffix
.
length
)
!==
-
1
;
}
}
...
@@ -109,8 +120,54 @@
...
@@ -109,8 +120,54 @@
return
form_gadget
.
getContent
();
return
form_gadget
.
getContent
();
})
})
.
push
(
function
(
content
)
{
.
push
(
function
(
content
)
{
var
data_array
,
protocol
,
i
;
if
(
!
content
.
data
)
{
content
.
data
=
[];
}
data_array
=
content
.
data
;
for
(
i
=
0
;
i
<
data_array
.
length
;
i
+=
1
)
{
data_array
[
i
].
blob
=
jIO
.
util
.
dataURItoBlob
(
data_array
[
i
].
url
);
data_array
[
i
].
url
=
undefined
;
}
if
(
content
.
data_url
)
{
protocol
=
(
new
URL
(
content
.
data_url
,
gadget
.
__path
)).
protocol
;
if
(
protocol
===
"
http:
"
)
{
if
(
window
.
location
.
protocol
!==
protocol
)
{
return
displayError
(
gadget
,
"
You cannot mixed http and https calls
"
);
}
}
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
ajax
({
dataType
:
"
blob
"
,
url
:
content
.
data_url
});
})
.
push
(
function
(
evt
)
{
content
.
data
.
push
({
blob
:
evt
.
target
.
response
,
file_name
:
content
.
data_url
});
return
content
;
},
function
()
{
return
displayError
(
gadget
,
'
Download
'
+
content
.
data_url
+
'
Failed
'
);
});
}
return
content
;
})
.
push
(
function
(
content
)
{
if
(
!
content
)
{
// fail while downloading
return
;
}
if
(
content
.
data
.
length
===
0
)
{
return
gadget
.
notifySubmitted
({
message
:
'
You need enter data
'
,
status
:
'
fail
'
});
}
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
RSVP
.
all
([
return
RSVP
.
all
([
gadget
.
getSetting
(
'
jio_storage_name
'
),
gadget
.
getSetting
(
'
jio_storage_name
'
),
gadget
.
getSetting
(
'
jio_storage_description
'
)
gadget
.
getSetting
(
'
jio_storage_description
'
)
...
@@ -133,7 +190,7 @@
...
@@ -133,7 +190,7 @@
}
}
for
(
i
=
0
;
i
<
data_array
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
data_array
.
length
;
i
+=
1
)
{
blob
=
jIO
.
util
.
dataURItoBlob
(
data_array
[
i
].
url
)
;
blob
=
data_array
[
i
].
blob
;
if
(
endsWith
(
data_array
[
i
].
file_name
,
"
.zip
"
))
{
if
(
endsWith
(
data_array
[
i
].
file_name
,
"
.zip
"
))
{
configuration
=
{
configuration
=
{
type
:
"
replicate
"
,
type
:
"
replicate
"
,
...
@@ -172,7 +229,6 @@
...
@@ -172,7 +229,6 @@
}
}
}
}
return
RSVP
.
all
(
promiseArray
);
return
RSVP
.
all
(
promiseArray
);
});
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
RSVP
.
all
([
return
RSVP
.
all
([
...
@@ -180,6 +236,7 @@
...
@@ -180,6 +236,7 @@
gadget
.
redirect
({
command
:
'
history_previous
'
})
gadget
.
redirect
({
command
:
'
history_previous
'
})
]);
]);
});
});
});
})
})
.
onStateChange
(
function
()
{
.
onStateChange
(
function
()
{
...
@@ -201,13 +258,24 @@
...
@@ -201,13 +258,24 @@
"
title
"
:
"
Upload files and Zip archive containing files
"
,
"
title
"
:
"
Upload files and Zip archive containing files
"
,
"
default
"
:
""
,
"
default
"
:
""
,
"
css_class
"
:
""
,
"
css_class
"
:
""
,
"
required
"
:
1
,
"
required
"
:
0
,
"
editable
"
:
1
,
"
editable
"
:
1
,
"
key
"
:
"
data
"
,
"
key
"
:
"
data
"
,
"
hidden
"
:
0
,
"
hidden
"
:
0
,
"
multiple
"
:
"
true
"
,
"
multiple
"
:
"
true
"
,
"
accept
"
:
"
application/zip,
"
+
result
[
1
],
"
accept
"
:
"
application/zip,
"
+
result
[
1
],
"
type
"
:
"
FileField
"
"
type
"
:
"
FileField
"
},
"
my_url
"
:
{
"
description
"
:
""
,
"
title
"
:
"
Fetch and Upload files and Zip archive containing files
"
,
"
default
"
:
""
,
"
css_class
"
:
""
,
"
required
"
:
0
,
"
editable
"
:
1
,
"
key
"
:
"
data_url
"
,
"
hidden
"
:
0
,
"
type
"
:
"
StringField
"
}
}
}
}
},
},
...
@@ -221,7 +289,7 @@
...
@@ -221,7 +289,7 @@
form_definition
:
{
form_definition
:
{
group_list
:
[[
group_list
:
[[
"
left
"
,
"
left
"
,
[[
"
my_file
"
]]
[[
"
my_file
"
]
,
[
"
my_url
"
]
]
]]
]]
}
}
});
});
...
...
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