Commit 2009d464ffe3ae15492a741bbe09508a3a350505
1 parent
fc35e016
Exists in
master
and in
11 other branches
adding proposal request
Showing
2 changed files
with
34 additions
and
6 deletions
Show diff stats
index.html
| ... | ... | @@ -57,6 +57,13 @@ |
| 57 | 57 | <span>{{body}}</span> |
| 58 | 58 | <div class='make-proposal'> |
| 59 | 59 | <title>Faça sua proposta</title> |
| 60 | + <form class='make-proposal-form' id='make-proposal-form-{{id}}'> | |
| 61 | + <input id="article_name" name="article[name]" type="text"> | |
| 62 | + <textarea id="article_abstract" name="article[abstract]"></textarea> | |
| 63 | + <input id='private_token' name='private_token' value='{{../private_token}}' type='hidden'> | |
| 64 | + <input id='content_type' name='content_type' value='ProposalsDiscussionPlugin::Proposal' type='hidden'> | |
| 65 | + <input type='submit' id='make-proposal-button' name='make-proposal-button' value='Submit'> | |
| 66 | + </form> | |
| 60 | 67 | </div> |
| 61 | 68 | <div class='support-proposal'> |
| 62 | 69 | <title> Apoie outras propostas</title> | ... | ... |
js/main.js
| ... | ... | @@ -9,12 +9,14 @@ var resultsPlaceholder = document.getElementById('proposal-result'); |
| 9 | 9 | |
| 10 | 10 | var topics; |
| 11 | 11 | |
| 12 | -var host = 'http://www.participa.br'; | |
| 13 | -//var host = 'http://localhost:3000'; | |
| 14 | -var private_token = '9350c1488fcae884ad955091a3d2d960'; | |
| 15 | -//var private_token = 'bd8996155f5ea4354e42fee50b4b6891'; | |
| 16 | -var proposal_discussion = '92856'; | |
| 17 | -//var proposal_discussion = '401'; | |
| 12 | +//var host = 'http://www.participa.br'; | |
| 13 | +var host = 'http://localhost:3000'; | |
| 14 | +//var private_token = '9350c1488fcae884ad955091a3d2d960'; //participa | |
| 15 | +//var private_token = 'bd8996155f5ea4354e42fee50b4b6891'; //casa | |
| 16 | +var private_token = '89419a2d331a17e815c3ecc53b303aac'; //local serpro | |
| 17 | +//var proposal_discussion = '92856'; //participa | |
| 18 | +var proposal_discussion = '377'; //local serpro | |
| 19 | +//var proposal_discussion = '401'; //casa | |
| 18 | 20 | |
| 19 | 21 | //var noosferoAPI = 'http://localhost:3000/api/v1/articles?private_token=89419a2d331a17e815c3ecc53b303aac&content_type=ProposalsDiscussionPlugin::Topic&parent_id=377&callback=?'; |
| 20 | 22 | |
| ... | ... | @@ -24,7 +26,9 @@ var noosferoAPI = host + '/api/v1/articles/' + proposal_discussion + '?private_t |
| 24 | 26 | $.getJSON(noosferoAPI) |
| 25 | 27 | .done(function( data ) { |
| 26 | 28 | data['host'] = host; |
| 29 | + data['private_token'] = private_token; | |
| 27 | 30 | resultsPlaceholder.innerHTML = template(data); |
| 31 | + //Actions for links | |
| 28 | 32 | $( 'a' ).click(function(event){ |
| 29 | 33 | var item = this.href.split('#').pop(); |
| 30 | 34 | if(item == 'proposal-categories'){ |
| ... | ... | @@ -57,6 +61,23 @@ $.getJSON(noosferoAPI) |
| 57 | 61 | } |
| 58 | 62 | event.preventDefault(); |
| 59 | 63 | }); |
| 64 | + | |
| 65 | + $('.make-proposal-form').submit(function (e) { | |
| 66 | + e.preventDefault(); | |
| 67 | + var proposal_id = this.id.split('-').pop(); | |
| 68 | + $.ajax({ | |
| 69 | + type: 'post', | |
| 70 | + url: host + '/api/v1/articles/' + proposal_id + '/children', | |
| 71 | + data: $('#'+this.id).serialize() | |
| 72 | + }) | |
| 73 | + .done(function( data ) { | |
| 74 | + }) | |
| 75 | + .fail(function( jqxhr, textStatus, error ) { | |
| 76 | + var err = textStatus + ", " + error; | |
| 77 | + console.log( "Request Failed: " + err ); | |
| 78 | + }); | |
| 79 | + }); | |
| 80 | + | |
| 60 | 81 | }) |
| 61 | 82 | .fail(function( jqxhr, textStatus, error ) { |
| 62 | 83 | var err = textStatus + ", " + error; | ... | ... |