editor - how to implement an easy approve and decline method without js/php knowledge?

editor - how to implement an easy approve and decline method without js/php knowledge?

mikefnasrmikefnasr Posts: 3Questions: 2Answers: 0

Dear

i am trying to implement an easy approve and decline method using datatables editor.
i am not a javascript nor php developer, so using the api or custom buttons might be the best solution for this however i have no idea where to start, appreciate if someone can point me to the right direction or tell me if i am thinking the wrong way.

what i am thinking to do is, have a page for users to add new countries, these entries will go to a temp table in a mysql database, another page for moderators, to see this data from the temp table, delete declined data from temp table, add approved data to real table.

the first page is easy, the second page ( the one for moderators ) need to do the following
- show entries from temp database ( done, using the same ajax source php file that connects to temp table )
- remove button, name changed to decline ( done, name changed using the i18n in the js file used, and ajax source pointing to the temp database, so correct data are being deleted when button is used )
- edit button, name changed to approve ( done, name changed using the i18n in the js file used, however, the ajax source is applied to temp database, so the edit function will edit the temp database... here comes my question )

how can i change the ajax source for ONLY the edit button in page 2 ( moderator page )

This way i can achieve basic approve / decline method using only the default DataTables and Editor functions

  • the editor will show the data from temp table ( filename.js ---> var table = ..... ajax: 'php/table.tmpcountry.php' )
  • the delete button will delete from temp database, implementing the decline function. ( filename.js ---> var editor = ajax: 'php/table.tmpcountry.php' )
  • the editor button will add the entry to the real table ( later on figure out a remove entry from temp ), implementing the approve function ( filename.js --> var editor(2???) = ajax: 'php/table.country.php' )

what do you think about the design above, will it be logical to do so without going deeply into api and javascript functions for buttons?

Thank you in advance

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Answer ✓

    Hi,

    Thanks for your question. The first thing to say (and not to put you off, but), is that Editor and DataTables are designed for software developers to you. They are not WYSIWYG software. You'll only get the most out of them by programming to their APIs.

    That being said, I think this example might be useful here. It has a custom button that will edit rows - you would basically do the same, but edit a flag in the database that states if the record is approved or not.

    Moreover, unless you are dealing with a huge amount of data, I'd suggest having a single table and apply a WHERE filter to it. The public view could simply be WHERE approved = 1 and the moderator view WHERE approved = 0. And delete and rows that get declined.

    I think that will make the Editor interaction very simple, and the example I linked to would help in implementing that.

    Regards,
    Allan

  • mikefnasrmikefnasr Posts: 3Questions: 2Answers: 0

    Hi Allan,

    Yep i totally agree, learning as i go...

    Thank you for your answer, working through the api of custom buttons, as it seems the correct way to do this.

    thanks again for the example and the time to point me to the right direction

    Regards,
    Mike

This discussion has been closed.