Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button or checkbox for draft creation #2594

Closed
grvsachdeva opened this issue Apr 8, 2018 · 11 comments
Closed

Button or checkbox for draft creation #2594

grvsachdeva opened this issue Apr 8, 2018 · 11 comments
Labels
design issue requires more design work and discussion (i.e. mockups and sketches) help wanted requires help by anyone willing to contribute

Comments

@grvsachdeva
Copy link
Member

grvsachdeva commented Apr 8, 2018

Part of #2307

I have completed first 2 parts of #2307 and now for completing the third one, some insights are needed. Currently, the creation of new post takes place from "Publish" button which first validates data from PublicLab editor and then after formatting a Post request is sent to notes_controller.rb from dist/PublicLab.Editor.js. Now, here are the ways we can provide user, option to create a draft, we need to choose one of them:

  1. After publishing the note, showing user notice that he can press the "Save as draft" button to store as draft. This button would be at https://publiclab.org/notes/gauravano/02-18-2018/gsoc-proposal-email-integration-project page.

  2. Adding a button next to publish, which would go through all the procedure same as publish and then for publishing the draft separate flow needs to be designed.

  3. Adding a checkbox near Publish button, which would require changes in /views/editor/rich.html.erb , an advantage of this method is we don't need to do any change in editor.(I vote for this ! )

Which option you consider appropriate @jywarren @ebarry ?

@sagarpreet-chadha sagarpreet-chadha added help wanted requires help by anyone willing to contribute design issue requires more design work and discussion (i.e. mockups and sketches) break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration labels Apr 8, 2018
@grvsachdeva grvsachdeva removed the break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration label Apr 8, 2018
@waqargithub
Copy link
Contributor

Curious to see what @jywarren and @ebarry say, and whether you think this issue might be a first-timer candidate.

@jywarren
Copy link
Member

I like Option 3 -- well thought through! I do think it could be a first-timer candidate... @Gauravano what extra things would we need to modify in the rich.html.erb template to make this possible? Would it simply add/remove a tag in the tag field when you click the checkbox? That seems plausible and keeps it all on the client side... what do you think?

@grvsachdeva
Copy link
Member Author

grvsachdeva commented Apr 24, 2018

We just need to add checkbox at right place on rich.html.erb and a JavaScript function which would be called when user clicks publish button. JS function would check if the box is marked or not and accordingly sends the status = 3 or 1 to the controller.

The follow-up of this, would be adding a button on research page to change status = 1 so that note would be visible publically. I have planned this, what do you think @jywarren?

@jywarren
Copy link
Member

jywarren commented Apr 24, 2018 via email

@grvsachdeva
Copy link
Member Author

grvsachdeva commented Apr 24, 2018

I am fine with using draft tag instead of status = 3 for the draft but then, we have to revert the work done as planned in #2307. Ok, we need to undo PR #2308 only.

@jywarren
Copy link
Member

Oops, no, don't do that! Sorry, i hadn't looked at this checklist for a while and forgot it was already implemented. But I also like the implementation you did -- using the params[:draft] as a boolean instead of directly setting params[:status]. So that addresses my worry too!

@jywarren
Copy link
Member

https://github.com/publiclab/plots2/pull/2308/files#diff-b9551b46e6321bfb977e1f52104c5768R114

Super, so the checkbox can be checked locally in JS, like this:

token: $('meta[name="csrf-token"]').attr('content')

Would we add another data sub-parameter? I believe that's right, as in https://github.com/publiclab/PublicLab.Editor/#setup

Super, sorry for being out of sync! 😀 👍

@grvsachdeva
Copy link
Member Author

grvsachdeva commented Apr 24, 2018

hi @jywarren, I was thinking of passing draft= true via destination URL so that I don't have to play with editor's code. It would go something like this

destination: '/notes/create?rich=true' in constructor

and if checkbox is marked on submission then destination would be changed like this:-
var newDestination = editor.options.destination +"&draft=true"; in JS function

What do you think about this approach @jywarren ?

@jywarren
Copy link
Member

jywarren commented Apr 24, 2018 via email

@grvsachdeva
Copy link
Member Author

grvsachdeva commented Apr 24, 2018

@jywarren , I tried the method mentioned in docs too and that is solid one as URL can be little messing when comes to different types of nodes (question, research, etc)

screenshot

So, Which one you find better @jywarren, I am ready for both ?

@grvsachdeva
Copy link
Member Author

Opened in #2667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design issue requires more design work and discussion (i.e. mockups and sketches) help wanted requires help by anyone willing to contribute
Projects
None yet
Development

No branches or pull requests

4 participants