Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Shelter Database
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
CHARISM
Shelter Database
Commits
50097e17
Commit
50097e17
authored
Aug 01, 2016
by
Maarten van der Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start integrating new shelter form"
parent
9ab8bef8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
64 deletions
+64
-64
src/web/templates/contribute.html
src/web/templates/contribute.html
+63
-9
src/web/templates/index.html
src/web/templates/index.html
+1
-1
src/web/templates/layout.html
src/web/templates/layout.html
+0
-54
No files found.
src/web/templates/contribute.html
View file @
50097e17
...
...
@@ -4,7 +4,11 @@
<div
class=
"content"
>
<h1>
Add your project
</h1>
<p>
The Shelter Database exists because of people like you!
<br
/>
We need you to help us build the content
</p>
<a
onclick=
"modalOpen()"
class=
"bt button button-red"
><i
class=
"fa fa-plus"
></i><span
class=
"text"
>
Add Project
</span></a>
{% if g.user.is_authenticated %}
<a
id=
"newShelter"
onclick=
"modalOpen()"
class=
"bt button button-red"
><i
class=
"fa fa-plus"
></i><span
class=
"text"
>
Add Project
</span></a>
{% else %}
<a
href=
"{{ url_for('join') }}"
class=
"bt button button-red"
><i
class=
"fa fa-user"
></i><span
class=
"text"
>
Please login to add your project
</span></a>
{% endif %}
</div>
</section>
<section
class=
""
style=
"background-color:#ecf0f1;"
>
...
...
@@ -28,22 +32,20 @@
<div
class=
"mymodal"
>
<div
class=
"content page1"
id=
"modalcontent"
>
<div
class=
"page page1"
>
<form
id=
"createShelterForm"
action=
"#"
class=
"navbar-form navbar-left"
method=
"GET"
name=
"save"
class=
"myform"
>
<div
class=
"mylabel"
>
Title of your project:
</div>
<div
class=
"myinput"
><input
type=
"
"
name=
""
placeholder=
"Title..
"
/></div>
<div
class=
"myinput"
><input
type=
"
text"
name=
"name"
placeholder=
"Name"
required=
"required
"
/></div>
<div
class=
"mylabel"
>
Country:
</div>
<form
class=
"myform"
>
<label
for=
"f1"
class=
"button button-drop"
>
<select
id=
"f1"
>
<option
value=
""
selected=
"selected"
>
Select
</option>
<option
value=
""
disabled
>
---
</option>
<option
value=
"moist tropical"
>
Afganistan
</option>
</select>
<select
id=
"countrySelect"
name=
"country"
data-live-search=
"true"
></select>
</label>
</form>
<!-- <a href="" class="button button-light button-drop button-stretch">Select</a> -->
<div
class=
"buttons"
>
<div
onclick=
"modalClose()"
class=
"button button-light"
><i
class=
"fa fa-times"
></i><span
class=
"text"
>
Cancel
</span></div>
<div
onclick=
"next()"
class=
"button button-light right"
><i
class=
"fa fa-arrow-right"
></i><span
class=
"text"
>
Next
</span></div>
<!--<button type="submit" id="createShelter" class="btn btn-default form-control" value="Create">Create</button> -->
<div
onclick=
"next()"
class=
"button button-light right"
><i
class=
"fa fa-arrow-right"
></i><span
class=
"text"
>
Next
</span></div>
</div>
</div>
<div
class=
"page page2"
>
...
...
@@ -87,6 +89,58 @@
</div>
</div>
</div>
<script>
$
(
document
).
ready
(
function
()
{
$
(
"
#newShelter
"
).
click
(
function
(
evt
)
{
var
filters
=
[{
"
name
"
:
"
name
"
,
"
op
"
:
"
eq
"
,
"
val
"
:
"
Country
"
}];
$
.
ajax
({
type
:
'
GET
'
,
url
:
'
/api/attribute
'
,
contentType
:
"
application/json
"
,
dataType
:
"
json
"
,
data
:
{
"
q
"
:
JSON
.
stringify
({
"
filters
"
:
filters
})},
success
:
function
(
result
)
{
result
.
objects
[
0
].
associated_values
.
map
(
function
(
country
)
{
$
(
"
#countrySelect
"
).
append
(
new
Option
(
country
.
name
,
country
.
id
));
})
$
(
'
.selectpicker
'
).
selectpicker
({
style
:
'
btn-default
'
,
size
:
false
});
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
){
//alert(errorThrown);
}
})
;
});
//Attach a submit handler to the form
$
(
"
#createShelterForm
"
).
submit
(
function
(
event
)
{
// Stop form from submitting normally
event
.
preventDefault
();
// Get some values from elements on the page:
var
$form
=
$
(
this
);
var
values
=
{};
form_complete
=
true
;
$
.
each
(
$form
.
serializeArray
(),
function
(
i
,
field
)
{
if
(
field
.
value
==
''
)
{
form_complete
=
false
;
}
values
[
field
.
name
]
=
field
.
value
;
});
url
=
$form
.
attr
(
"
action
"
);
if
(
form_complete
)
{
// Send the data using post
name_of_shelter
=
values
[
"
name
"
]
country_value_id
=
values
[
"
country
"
];
country_name
=
$
(
'
#countrySelect option:selected
'
).
text
()
create_shelter
(
name_of_shelter
,
country_value_id
,
country_name
);
}
else
{
alert
(
"
Please fill all the fields of the form.
"
);
}
});
});
</script>
<script
type=
"text/javascript"
>
var
cnt
=
document
.
getElementById
(
"
modalcontent
"
)
...
...
src/web/templates/index.html
View file @
50097e17
...
...
@@ -81,7 +81,7 @@
document
.
getElementById
(
"
searchinput
"
).
addEventListener
(
"
keyup
"
,
function
(
e
)
{
e
.
preventDefault
();
if
(
e
.
keyCode
==
13
)
{
window
.
location
.
href
=
"
dashboard
s
"
window
.
location
.
href
=
"
dashboard
"
}
});
</script>
...
...
src/web/templates/layout.html
View file @
50097e17
...
...
@@ -90,59 +90,5 @@
<!-- Placed at the end of the document so the pages load faster -->
<script
src=
"{{ url_for('static', filename = 'lib/bootstrap/dist/js/bootstrap.min.js') }}"
></script>
<script
src=
"{{ url_for('static', filename = 'lib/bootstrap-select/dist/js/bootstrap-select.min.js') }}"
></script>
<!--<script>
$(document).ready(function() {
$('ul.navbar-right > li.dropdown').show();
$("#newShelter").click(function(evt) {
var filters = [{"name":"name","op":"eq","val":"Country"}];
$.ajax({
type: 'GET',
url: '/api/attribute',
contentType: "application/json",
dataType: "json",
data: {"q": JSON.stringify({"filters": filters})},
success: function(result) {
result.objects[0].associated_values.map(function(country) {
$("#countrySelect").append(new Option(country.name, country.id));
})
$('.selectpicker').selectpicker({style: 'btn-default',
size: false});
},
error: function(XMLHttpRequest, textStatus, errorThrown){
//alert(errorThrown);
}
}) ;
});
//Attach a submit handler to the form
$( "#createShelterForm" ).submit(function( event ) {
// Stop form from submitting normally
event.preventDefault();
// Get some values from elements on the page:
var $form = $(this);
var values = {};
form_complete = true;
$.each($form.serializeArray(), function(i, field) {
if (field.value == '') {
form_complete = false;
}
values[field.name] = field.value;
});
url = $form.attr("action");
if (form_complete) {
// Send the data using post
name_of_shelter = values["name"]
country_value_id = values["country"];
country_name = $('#countrySelect option:selected').text()
create_shelter(name_of_shelter, country_value_id, country_name);
} else {
alert("Please fill all the fields of the form.");
}
});
});
</script>-->
</body>
</html>
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