jordanlev / c5_boilerplate_crud

Boilerplate code for basic dashboard CRUD operations in Concrete5
35 stars 16 forks source link

Save & Add New + Save & Duplicate #7

Closed cryophallion closed 10 years ago

cryophallion commented 10 years ago

Many people prefer to not have to go back to the list view and click again to add a new item. Additionally, for example in cars, you may have several cars of different years and you want to duplicate most of the info, but change a couple of fields. These changes add that functionality

NOTES: You have to use a manual hidden id field since C5's form helper overrides it with the post variable (submitting a pull request for a fix for this to the C5 core soon) The buttons were changed to the form instead of interface button style since they needed different names. Formatting was left intact

cryophallion commented 10 years ago

One further note I forgot on the commit. Since body types has a unique slug, I left off duplicate, and just included add new

jordanlev commented 10 years ago

Hi, Thanks again for your contributions (even though I'm not merging them all). So... I actually just finished a project that had "duplicate" functionality. I implemented it as another button in the "view" list though (so there is "Edit", "Duplicate", and "Delete" next to each item in the list). All it does is call up the "add" form and pre-populate it with data from an existing record. The benefit of this is it's highly generic and can be used for pretty much any situation, because the duplicate function is not actually saving anything but rather just loading up default data -- so there is still a validation step required before the user saves the new duplicate record (which would catch any edge cases such as checking for unique url slugs).

I do like your idea for the "Save and Add New" button -- would you mind submitting a new pull request that has only that feature in it?

If I add the duplicate function and you ad the "Save and Add New" function, then I imagine they could be easily combined into a third feature... a "Save and Add New Duplicate" button.

One last thought... it seems to me that the "Save and Add New" button(s) might only be useful on the "Add New" form, not when you're editing an existing record. What are your thoughts on that?

Thanks again.

cryophallion commented 10 years ago

Ok, in order:

  1. Sure, I'll upload just the Save& Add New tonight
  2. That way of doing things is definitely a cool idea, I look forward to seeing how you do it in the crud table.
  3. It's always dangerous to ask someone their opinion, because they are sometimes not the same as your own :) So, I'm going to deal with both issues:
  4. Only adding it to ADD functions - I disagree with this, only because I routinely saw a client on a site I did (on another cms) have to go in and edit an item, and then begin their add new. For example, a generic wine brand. Then the next year, he edits it to be 2009, and ADDs 2010. So, it is quite useful and a common use case to edit first, in my experience. So I would say keep it in all situations personally.
  5. Duplicate: I agree your implementation is more generic, and I really like the idea. However, I would posit that BOTH options are useful. Say you are editing the wine, and want to duplicate it inline? Then you need to go back to the list again, which is the problem we are trying to avoid. Having both duplicates as options gives users flexibility to use the backend the way they want to, and not the way we force them into.

Mind you, and let me be clear: This is your project, and I will completely understand if you decide against these options. I just want to present a reasonable contrasting view before you make your decision. I find informed decisions to be much better reasoned, and make projects better in the long term. Let me know your rebuttals, I think we both just want what is best for this library.

jordanlev commented 10 years ago

See https://github.com/jordanlev/c5_boilerplate_crud/pull/9#issuecomment-40539273 for resolution of these excellent points you brought up. Thanks.