Skip to content
This repository has been archived by the owner on Sep 17, 2018. It is now read-only.

New api to support Two form in one page. #36

Closed
wants to merge 15 commits into from
Closed

Conversation

anuragteapot
Copy link
Member

@anuragteapot anuragteapot commented Jul 14, 2018

Summary of Changes

New API to support custom form with different id's. It supports more than two form in one page.
Mulitiselect : JHtml::_('behavior.multiselect', 'your id ');
like take a id = updateform

JHtml::_('behavior.multiselect', 'updateForm');

Grid id : HTMLHelper::_('grid.id', $i, $value->hash_id, 'updateForm');

Publish : JHtml::_('jgrid.published', $value->state, $i, 'template.', 1, 'updateForm');

Tool Bar : ToolbarHelper::custom('template.deleteHistory', 'delete', 'move', 'JTOOLBAR_DELETE', true, 'updateForm');

Pass your form id as a parameter.

Hope this ok. But the review is necessary.

Testing Instructions

Add an admin form with id = adminfrom and add the second form with id=what ever you want. In one page

Expected result

All form working as expected.

Actual result

Old API only select the first form in the page with id = adminform. Which causes the error in working on the second form.

Documentation Changes Required

Yes

@dgrammatiko Please take a look here. Is any thing left to support custom form id ?

@anuragteapot anuragteapot requested review from dgrammatiko, wilsonge, astridx and laoneo and removed request for astridx July 14, 2018 14:54
*
* @return mixed String of html with a checkbox if item is not checked out, null if checked out.
*
* @since 1.5
*/
public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid', $stub = 'cb')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add the new parameter at the end or you’re breaking b/c

@@ -155,7 +168,7 @@ public static function state($states, $value, $i, $prefix = '', $enabled = true,
* @see JHtmlJGrid::state()
* @since 1.6
*/
public static function published($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb', $publish_up = null, $publish_down = null)
public static function published($value, $i, $prefix = '', $enabled = true, $formId = null, $checkbox = 'cb', $publish_up = null, $publish_down = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @see JHtmlJGrid::state()
* @since 1.6
*/
public static function isdefault($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb')
public static function isdefault($value, $i, $prefix = '', $enabled = true, $formId = null, $checkbox = 'cb')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function checkedout($i, $editorName, $time, $prefix = '', $enabled = false, $checkbox = 'cb')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLIB_HTML_MOVE_UP', $enabled = true, $checkbox = 'cb')
public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLIB_HTML_MOVE_UP', $enabled = true, $formId = null, $checkbox = 'cb')
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, it needs to be the last one, otherwise, we have a b/c break!!!

* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function orderDown($i, $task = 'orderdown', $prefix = '', $text = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $checkbox = 'cb')
public static function orderDown($i, $task = 'orderdown', $prefix = '', $text = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $formId = null, $checkbox = 'cb')
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@anuragteapot
Copy link
Member Author

@dgrammatiko Done! :)

@anuragteapot
Copy link
Member Author

@dgrammatiko I think i need to create this PR to main repo right ?

Anu1601CS added 3 commits July 14, 2018 23:09
@dgrammatiko
Copy link
Contributor

Yes this needs to be done against the 4.0-dev

->text($text)
->task($task)
->listCheck($list);
if ($formId !== null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we save some lines if we do it like this

...
if ($formId !== null)
{
   $this->form($formId);
}
$this->name($name);
$this->text($text);
$this->task($task);
$this->listCheck($list);
...

@astridx
Copy link
Contributor

astridx commented Jul 14, 2018

I have tested this branch successful.

  1. I changed id and name of the form in file /administrator/components/com_installer/tmpl/discover/default.php to name="adminForm1" id="adminForm1" -> The form did not work any more. I could not install a discovered extension.
  2. I changed the line JHtml::_('behavior.multiselect'); to JHtml::_('behavior.multiselect', 'adminForm1');. Later I saw, that this is not needed.
  3. I changed the line <?php //echo JHtml::_('grid.id', $i, $item->extension_id); ?> to <?php echo HTMLHelper::_('grid.id', $i, $item->extension_id, false, 'cid', 'cb', 'adminForm1'); ?>
  4. Now it was possible for me to install a discovered extension

@astridx
Copy link
Contributor

astridx commented Jul 14, 2018

Now I am not sure how to merge this branch. Should we merge here in the project, or belongs it to the Main project?
@laoneo @dgrammatiko What do you think? Actually, it would belong to the main project, I think. But we can only continue working if we have these changes. How long would it take to merge this in the main project?

@anuragteapot
Copy link
Member Author

@astridx Yes, these changes is done! for our project. So, i think we need to merge here ?
@laoneo

@dgrammatiko
Copy link
Contributor

Please make a or in the 4.0 branch and then we can merge it there. The code will be shortly available here then

@anuragteapot anuragteapot mentioned this pull request Jul 17, 2018
@astridx
Copy link
Contributor

astridx commented Jul 18, 2018

Close as merged in #39

@astridx astridx closed this Jul 18, 2018
@astridx astridx deleted the new-Api branch July 18, 2018 09:54
@anuragteapot anuragteapot self-assigned this Aug 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants