Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
piphone
piphone-front
Commits
49b45031
Commit
49b45031
authored
Feb 07, 2017
by
okhin
Browse files
Updating the clla to POST feedbacks
parent
10bd8e26
Pipeline
#845
passed with stage
in 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Api.php
View file @
49b45031
...
...
@@ -17,10 +17,19 @@ class Api {
// Generic post function for REST API
static
function
post
(
$url
,
$data
)
{
$client
=
new
Client
([
'base_uri'
=>
API_BASE
,
'defaults'
=>
[
'headers'
=>
[
'Content-type'
=>
'applications/json'
]]]);
$url
=
API_BASE
.
$url
.
"/?format=json"
;
$result
=
$client
->
request
(
'POST'
,
$url
,
array
(),
$data
);
return
$result
->
getBody
();
try
{
$client
=
new
Client
([
'base_uri'
=>
API_BASE
,
'defaults'
=>
[
'headers'
=>
[
'Content-type'
=>
'applications/json'
]]]);
$url
=
API_BASE
.
$url
.
"/?format=json"
;
$result
=
$client
->
request
(
'POST'
,
$url
,
[
'body'
=>
json_encode
(
$data
),
"headers"
=>
[
'Content-Type'
=>
'application/json'
]]);
return
$result
->
getBody
();
}
catch
(
Exception
$e
)
{
echo
$e
;
if
(
$e
->
hasResponse
())
{
echo
$e
->
getResponse
()
->
getBody
();
}
else
{
echo
$e
;
}
}
}
// Asking for campaign informations
...
...
@@ -74,9 +83,9 @@ class Api {
// Posting a feedback
static
function
post_feedback
(
$contact_id
,
$comment
,
$feedback_category
=
''
)
{
$data
=
array
(
"c
ontact_id
"
=>
$contact_id
,
"c
allee
"
=>
$contact_id
,
"comment"
=>
$comment
,
"
feedback_
category"
=>
$feedback_category
"category"
=>
$feedback_category
);
$json
=
Api
::
post
(
"campaigns/"
.
CAMPAIGN_ID
.
"/feedbacks"
,
$data
);
return
json_decode
(
$json
,
true
);
...
...
templates/feedbackform.html
View file @
49b45031
<!-- Let's split this page in two -->
<div
class=
"row"
>
<div
class=
"col s6"
>
<include
href=
"argumentation.html"
>
</div>
<div
class=
"col s6"
>
<div
class=
"card"
>
...
...
@@ -35,12 +34,11 @@
<p
class=
"small"
>
{{ _("Please tell us what happened if you were able to talk to someone. Your feedback is important to us.") }}
</p>
<form
class=
"form"
method=
"post"
action=
"/feedback/"
>
<input
type=
"hidden"
id=
"contact_id"
name=
"contact_id"
value=
"{{ @contact_id }}"
/>
<select
name=
"feedback_category"
id=
"feedback_category"
class=
"input-field"
>
<repeat
group=
"{{ @feedback_categories }}"
value=
"{{ @feedback_category }}"
>
<span>
<input
required
type=
"radio"
name=
"feedback_category"
value=
"{{ @feedback_category.id }}"
id=
"f{{ @feedback_category.id }}"
/>
<label
for=
"f{{ @feedback_category.id }}"
>
{{ @feedback_category.name }}
</label>
</span>
<option
value=
"{{ @feedback_category.id }}"
>
{{ @feedback_category.name }}
</option>
</repeat>
</select>
<div
class=
"input-field"
>
<textarea
class=
"materialize-textarea"
id=
"feedback"
name=
"feedback"
></textarea>
</div>
...
...
@@ -136,5 +134,6 @@
$
(
document
).
ready
(
function
()
{
update_call
(
call
);
interval
=
window
.
setInterval
(
fetch
,
3000
);
$
(
'
select
'
).
material_select
();
});
</script>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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