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

Fix issue #237 #366

Merged
merged 9 commits into from Feb 22, 2012
Merged

Fix issue #237 #366

merged 9 commits into from Feb 22, 2012

Conversation

DaSourcerer
Copy link
Contributor

The rows in a CGridView have a visibility property. So do single entries in CDetailView. Can we have the same in CTabView?

@mdomba
Copy link
Member

mdomba commented Feb 17, 2012

In CGridView there is a visible property for a certain column not for a row...
In CDetailView there is a visible property for an attribute

CTabView displays multiple tabs where only one is visible at a time...

Your "visible" property just decides if to render a tab or not... I don't see the difference if you just check this expression and then decide if to add the content as a tab or not...

@mdomba mdomba closed this Feb 17, 2012
@DaSourcerer
Copy link
Contributor Author

Exactly. CGridView.columns.visible controls if a certain column is rendered or not. CDetailView.attributes.visible controls the visibility of a specific attribute. The idea of this patch has been to bring the same to specific tabs of CTabView. I've seen a number of occasions were this would have been helpful to me and others. The alternative is to perform more or less complex array manipulations on CTabView.tabs, which tends to result in illegible code after some time.

Really no way to get this in?

@mdomba
Copy link
Member

mdomba commented Feb 18, 2012

I don't see how this is the same... a GridView shows all columns at once like CDetailView shows all attribute at once... and there is the visible attribute that can be evaluated at run-time so to decide if the column/attribute is visible depending on some current record value... note that this cannot be done otherwise... I mean you cannot evaluate that expression before the rendering method...

A tabview does not show all tabs at once only one at the time... in fact only one tab is visible and all other are not visible... so the "visible" property name is not logical...

and as I see it, you can just evaluate the condition and then decide if to render the TAB or not

maybe I'm wrong... please show me a use case for this... but note that as per your implementation the visible property is checked before rendering any tab so it's like I wrote before... you can just check the condition and depending on that decide if to add the tab or not.

@mdomba
Copy link
Member

mdomba commented Feb 18, 2012

Ops... sorry for the previous comment... When writing I was thinking on the CButtonColumn::buttons visible option, that is evaluated at runtime...

Actually your proposal is good I see how it can help writing simpler code, so I'm reopening this issue.

My only concern is the name of this property as how I wrote before the definition of CTabView is "displays multiple tabs where at any time, only one tab is visible" so the visible property could be confusing to someone as here the "visible"=>false would mean "do not render this tab"

On the other side "visible" would be consistent with other components like CGridView and CDetailView.

I'm for this change but before pulling would like to hear other core devs (@samdark, @qiangxue)

@mdomba mdomba reopened this Feb 18, 2012
@samdark
Copy link
Member

samdark commented Feb 18, 2012

I don't actually think that array manipulations are that complex. Also if is much more explicit.

$tabs = array();
$tabs['tab1'] = array(…);
if($condition)
{
   $tabs['tab2'] = array(…);
}

vs

$tabs = array(
  'tab1' => array(…),
  'tab2' => array(
    'render' => $condition,
    …
  ),
);

@DaSourcerer
Copy link
Contributor Author

@mdomba Thanks for reconsidering this. That's more than I have hoped for.

@samdark You are indeed right. if is more explicit. But take into account that your example is quite simple. If you've got a CTabView with more than five tabs (possibly with a different set of tabs with different content for selected user groups), things tend to get really, really messy. I've worked around this with CMap::mergeArray(), unset() and other tricks. But in the end, a visibility prop would have been the far better solution.

@mdomba
Copy link
Member

mdomba commented Feb 18, 2012

@samdark as @DaSourcerer explained without this option and depending on user needs complicate array manipulation could be needed... and the same attribute "visible" is added for a CGridView column where too an if would be enough

@@ -97,6 +97,7 @@ class CTabView extends CWidget
* <li>url: a URL that the user browser will be redirected to when clicking on this tab.</li>
* <li>data: array (name=>value), this will be passed to the view when 'view' is specified.
* This option is available since version 1.1.1.</li>
* <li>visible: whether this tab is visible. Defaults to true.</li>
* </ul>
Copy link
Member

Choose a reason for hiding this comment

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

You should add a This option is available since version 1.1.11. like it is there for the data attribute.

@ghost ghost assigned mdomba Feb 21, 2012
@mdomba
Copy link
Member

mdomba commented Feb 22, 2012

Please update your repo to latest version, merge it and push to your request branch. This way we will be able to merge automatically.

As for changelog consider using this line

@DaSourcerer
Copy link
Contributor Author

Here we go. I hope I didn't blow it.

samdark added a commit that referenced this pull request Feb 22, 2012
@samdark samdark merged commit c85b8d7 into yiisoft:master Feb 22, 2012
@samdark
Copy link
Member

samdark commented Feb 22, 2012

Merged. @mdomba please check if your changes are there.

@mdomba
Copy link
Member

mdomba commented Feb 22, 2012

all good (y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants