mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-03 19:44:22 +00:00
Tests/Manual/People: Enforce Age column placement after Birthdate via table delegate
This commit is contained in:
1 parent
d2f1112b6b
commit
6bcc6bce56
2 files changed
+44
-1
No files matched your search
@@ -185,9 +185,9 @@ var NotesMask = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4
|
||||
[self _addColumn:@"firstName" title:@"First Name" width:110 editable:YES dataView:nil];
|
||||
[self _addColumn:@"department" title:@"Department" width:110 editable:YES dataView:nil];
|
||||
[self _addColumn:@"city" title:@"City" width:110 editable:YES dataView:nil];
|
||||
[self _addColumn:@"birthDate" title:@"Birthdate" width:200 editable:NO dataView:[self _textDataViewWithFormatter:dateFormatter alignment:CPLeftTextAlignment]];
|
||||
var ageColumn = [self _addColumn:@"age" title:@"Age" width:46 editable:NO dataView:[self _textDataViewWithFormatter:nil alignment:CPRightTextAlignment]];
|
||||
[[ageColumn headerView] setAlignment:CPRightTextAlignment];
|
||||
[self _addColumn:@"birthDate" title:@"Birthdate" width:200 editable:NO dataView:[self _textDataViewWithFormatter:dateFormatter alignment:CPLeftTextAlignment]];
|
||||
var salaryColumn = [self _addColumn:@"salary" title:@"Salary" width:90 editable:YES dataView:[self _textDataViewWithFormatter:numberFormatter alignment:CPRightTextAlignment]];
|
||||
[[salaryColumn headerView] setAlignment:CPRightTextAlignment];
|
||||
|
||||
@@ -218,6 +218,9 @@ var NotesMask = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4
|
||||
[_tableView setAutosaveName:@"People.PeopleTable"];
|
||||
[_tableView setAutosaveTableColumns:YES];
|
||||
|
||||
// A column order saved by an earlier version can separate Age from Birthdate.
|
||||
[self _keepAgeAfterBirthdate];
|
||||
|
||||
[scrollView setDocumentView:_tableView];
|
||||
[pane addSubview:scrollView];
|
||||
|
||||
@@ -329,6 +332,39 @@ var NotesMask = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Age follows Birthdate
|
||||
|
||||
/*
|
||||
The Age column always comes right after the Birthdate column. Age cannot be dragged by
|
||||
itself. When any column drag ends, Age moves back after Birthdate. That covers a drag of
|
||||
Birthdate, and a drop of another column between the two.
|
||||
*/
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldReorderColumn:(CPInteger)aColumnIndex toColumn:(CPInteger)aNewColumnIndex
|
||||
{
|
||||
return [[[aTableView tableColumns] objectAtIndex:aColumnIndex] identifier] !== @"age";
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView didDragTableColumn:(CPTableColumn)aTableColumn
|
||||
{
|
||||
[self _keepAgeAfterBirthdate];
|
||||
}
|
||||
|
||||
/*
|
||||
Moves the Age column to the index after the Birthdate column. When Age is to the left of
|
||||
Birthdate, removing Age shifts Birthdate one place to the left, so the target is
|
||||
Birthdate's own index.
|
||||
*/
|
||||
- (void)_keepAgeAfterBirthdate
|
||||
{
|
||||
var birthDateIndex = [_tableView columnWithIdentifier:@"birthDate"],
|
||||
ageIndex = [_tableView columnWithIdentifier:@"age"];
|
||||
|
||||
if (birthDateIndex === CPNotFound || ageIndex === CPNotFound || ageIndex === birthDateIndex + 1)
|
||||
return;
|
||||
|
||||
[_tableView moveColumn:ageIndex toColumn:ageIndex < birthDateIndex ? birthDateIndex : birthDateIndex + 1];
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Contextual menu
|
||||
|
||||
/*
|
||||
|
||||
@@ -39,6 +39,8 @@ spaces, because the legacy toolchain does not accept them.
|
||||
5. "Müller (diacritics test)" must match Müller with predicate `muller` (`[cd]`).
|
||||
6. Type in the search field: filter combines with the selected folder (AND).
|
||||
7. Sort by every column header; reorder and resize columns; reload: column layout restored.
|
||||
Age always follows Birthdate: drag Birthdate, or drop another column between the two, and
|
||||
Age moves back after Birthdate on drop. Age cannot be dragged by itself.
|
||||
8. Select people, drag onto a group: badge increases. Drag onto the GROUPS header: new group created and selected.
|
||||
9. Drag groups / smart folders to reorder them within their section; reload: order persisted.
|
||||
10. Edit a cell (name, salary, Mgr checkbox) and the detail pane fields: other views and badges follow;
|
||||
@@ -110,6 +112,11 @@ to build with a web component framework.
|
||||
- Delete Selected: deletes the selection, whether it has one row or many, contiguous or not.
|
||||
It is disabled when nothing is selected.
|
||||
|
||||
The Age column, calculated from the birth date and the browser's date, always follows the
|
||||
Birthdate column. The table delegate refuses a drag of Age by itself, and moves Age back after
|
||||
Birthdate when any column drag ends. This exercises `tableView:shouldReorderColumn:toColumn:`
|
||||
and `tableView:didDragTableColumn:`.
|
||||
|
||||
### Window and menus
|
||||
|
||||
8. In edit mode, Hide Details is disabled everywhere: menu, toolbar and button bar.
|
||||
|
||||
Reference in new issue
Block a user