Comments

merlinofchaos’s picture

Status: Needs review » Needs work

Hmm. I think this should be a per field setting, not a global setting. I don't think a global setting is all that useful.

dawehner’s picture

Yes, i didn't know a lot of views at that time :)

Couldn't the views table style read out

function options_defintion()....
    $options['order'] = array('default' => 'ASC');
...

if sort handlers and use this?

What did you meaned with "make this a setting":
- A setting for the site admin?
- A setting for the developer :)

dagmar’s picture

@dereine: Here is an example of settings applied per field #383994: Column align

funkmasterjones’s picture

StatusFileSize
new3.43 KB

wasn't too hard to implement looking at both patches

surprised nobody else go to it before me (that I know of)

a better patch would check if fields are numeric (desc) or alphanumeric (asc) a set a default automatically
but this is good enough for me

Derek

dawehner’s picture

Status: Needs work » Needs review

.

funkmasterjones’s picture

StatusFileSize
new3.39 KB

oops made a mistake heres the right one

I'd suggest removing the old default sort option at the bottom as its no longer needed

merlinofchaos’s picture

StatusFileSize
new4.76 KB

The above patch had a couple of code style issues, plus it failed to add extra columns in the table where the column was not available. Plus, we should use dependency checking to make the default sort order field not visible if sorting is not enabled (since it is pointless).

dawehner’s picture

I'm wondering about:


+          '#default_value' => !empty($this->options['info'][$field]['default_sort_order']) ? $this->options['info'][$field]['default_sort_order'] : 'ASC',

On every other part of the patch it is used 'asc'

dawehner’s picture

StatusFileSize
new4.02 KB

Additonal


+        $initial = empty($options['info'][$field]['default_sort_order']) ? $options['info'][$field]['default_sort_order'] : 'asc';

made no sense for me.

It shoould be !empty

Here is a quick rerole

crashtest_’s picture

Status: Needs review » Reviewed & tested by the community

Looks good and works as it should.

Edit: I think I was mistaken about this. Testing further.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Needs review

Setting back to NR based on edit in #10

tic2000’s picture

I did not see this patch and I modified a views module on a site to have this option.
The patch looks almost identical to what I did with 2 exceptions.

+++ plugins/views_plugin_style_table.inc
@@ -51,12 +51,14 @@ class views_plugin_style_table extends views_plugin_style {
-      $this->order = !empty($this->options['order']) ? $this->options['order'] : 'asc';
+      $default_sort = !empty($this->options['info'][$sort]['default_sort_order']) ?  $this->options['info'][$sort]['default_sort_order'] : 'asc';
+      $this->order = !empty($this->options['order']) ? $this->options['order'] : $default_sort;

This is not needed.

+++ plugins/views_plugin_style_table.inc
@@ -51,12 +51,14 @@ class views_plugin_style_table extends views_plugin_style {
-      $this->order = !empty($_GET['sort']) ? strtolower($_GET['sort']) : 'asc';
+      $default_sort = !empty($this->options['info'][$sort]['default_sort_order']) ?  $this->options['info'][$sort]['default_sort_order'] : 'asc';
+      $this->order = !empty($_GET['sort']) ? strtolower($_GET['sort']) : $default_sort;

Same as above.

I say the default order should be left as is.
Even better, the default order options should be removed and just leave the radios for the default column to sort on.

Powered by Dreditor.

merlinofchaos’s picture

Assigned: Unassigned » dawehner

dereine: Can you reroll based on #12?

dawehner’s picture

StatusFileSize
new3.07 KB

removed the changes as described in #12

@tic2000
Can you look again at the test file?

tic2000’s picture

StatusFileSize
new3.68 KB
+++ plugins/views_plugin_style_table.inc
@@ -201,6 +203,14 @@ class views_plugin_style_table extends views_plugin_style {
+          '#options' => array('asc' => t('Up'), 'desc' => t('Down')),

The text should be consistent with the default sort order (Ascending/Descending)

The patch seems to be for Views 6.3. I manually applied it to 6.2 and it works as expected.
If I have enough time tomorrow I will make a test site and install Views 6.3 and try on that too (just to be sure, I don't expect surprises on that version).

Beside the small issue above seems RTBC to me.

For convenience here is the patch resulted from the 6.2 branch.

Powered by Dreditor.

tic2000’s picture

Status: Needs review » Needs work
dawehner’s picture

Status: Needs work » Needs review

New option description is definitive much better.

tic2000’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.68 KB

To me it was confusing at first and consistency is always better.

Here is the patch for 6.3 with the changed text. merlinofchaos can decide which one he prefers.

merlinofchaos’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Reviewed & tested by the community » Fixed

Since this is a new feature, I have elected to place this only in Views 3. Committed to D6 and D7.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.