Skip to content

Commit

Permalink
Merge pull request #751 from fbarthez/pr/ERMDColumnSelector
Browse files Browse the repository at this point in the history
New ERMD2WColumnSelector component
  • Loading branch information
darkv authored Sep 9, 2016
2 parents 298da91 + 40f636a commit 539d18c
Show file tree
Hide file tree
Showing 18 changed files with 437 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.webobjects.foundation.NSPropertyListSerialization;
import com.webobjects.foundation.NSSelector;

import er.directtoweb.components.repetitions.ERDAttributeRepetition;
import er.extensions.batching.ERXBatchNavigationBar;
import er.extensions.components.ERXSortOrder;
import er.extensions.eof.ERXConstant;
Expand Down Expand Up @@ -220,17 +221,24 @@ public static class _UserPreferenceHandler {
public _UserPreferenceHandler() {
NSNotificationCenter.defaultCenter().addObserver(this, new NSSelector("handleBatchSizeChange", ERXConstant.NotificationClassArray), ERXBatchNavigationBar.BatchSizeChanged, null);
NSNotificationCenter.defaultCenter().addObserver(this, new NSSelector("handleSortOrderingChange", ERXConstant.NotificationClassArray), ERXSortOrder.SortOrderingChanged, null);
NSNotificationCenter.defaultCenter().addObserver(this, new NSSelector("handleDisplayVariantChange", ERXConstant.NotificationClassArray), ERDAttributeRepetition.DisplayVariantChanged, null);
}

public void handleBatchSizeChange(NSNotification n) { handleChange("batchSize", n); }
public void handleSortOrderingChange(NSNotification n) { handleChange("sortOrdering", n); }
public void handleDisplayVariantChange(NSNotification n) { handleChange("displayVariant", n); }

public void handleChange(String prefName, NSNotification n) {
if (ERCoreBusinessLogic.actor() != null) {
NSKeyValueCoding context=(NSKeyValueCoding)n.userInfo().objectForKey("d2wContext");
if (context!=null && context.valueForKey("pageConfiguration") != null) {
if ("displayVariant".equals(prefName)) {
String key = prefName + "." + context.valueForKey("propertyKey") + "." + context.valueForKey("pageConfiguration");
userPreferences().takeValueForKey(n.object(), key);
} else {
userPreferences().takeValueForKey(n.object(),
prefName+"."+(String)context.valueForKey("pageConfiguration"));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import com.webobjects.appserver.WOContext;
import com.webobjects.appserver.WOResponse;
import com.webobjects.foundation.NSArray;
import com.webobjects.foundation.NSKeyValueCoding;
import com.webobjects.foundation.NSMutableArray;

import er.directtoweb.ERD2WContainer;
import er.directtoweb.ERDirectToWeb;
import er.directtoweb.components.ERDCustomComponent;
import er.directtoweb.pages.ERD2WPage;
import er.extensions.ERXExtensions;
import er.extensions.appserver.ERXWOContext;
import er.extensions.foundation.ERXStringUtilities;

/**
* Class for DirectToWeb Component ERDAttributeRepetition.
Expand All @@ -24,6 +27,7 @@
* @d2wKey propertyKey
* @d2wKey alternateKeyInfo
* @d2wKey sectionsContents
* @d2wKey displayVariant
*/
public class ERDAttributeRepetition extends ERDCustomComponent {
/**
Expand All @@ -36,6 +40,8 @@ public class ERDAttributeRepetition extends ERDCustomComponent {
/** logging support */
private static final Logger log = Logger.getLogger(ERDAttributeRepetition.class);

public static final String DisplayVariantChanged = "DisplayVariantChanged";

/**
* Public constructor
* @param context the context
Expand Down Expand Up @@ -79,7 +85,44 @@ public boolean hasPropertyName() {
* @return the display variant, if specified
*/
public String displayVariant() {
return (String)d2wContext().valueForKey(ERD2WPage.Keys.displayVariant);
String displayVariant = (String)d2wContext().valueForKey(ERD2WPage.Keys.displayVariant);
if (!("omit".equals(displayVariant) || "blank".equals(displayVariant))) {
// the property is neither omitted nor blanked via the rules,
// so we let the user decide
String key = ERD2WPage.Keys.displayVariant + "." + propertyKey();
String preference =
(String) userPreferencesValueForPageConfigurationKey(key);
if (!ERXStringUtilities.isBlank(preference)) {
displayVariant = preference;
}
}
return displayVariant;
}

/**
* Utility method to get a value from the user prefs.
*
* @param key
*/
protected Object userPreferencesValueForKey(String key) {
Object result = null;
NSKeyValueCoding userPreferences = (NSKeyValueCoding) d2wContext().valueForKey(
"userPreferences");
if (userPreferences != null) {
result = userPreferences.valueForKey(key);
}
return result;
}

/**
* Utility method to get a value for the current page configuration from the
* user prefs.
*
* @param key
*/
protected Object userPreferencesValueForPageConfigurationKey(String key) {
key = ERXExtensions.userPreferencesKeyFromContext(key, d2wContext());
return userPreferencesValueForKey(key);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,101 @@ ul.L2WithChildren li.Nav2Selected {
}


/* COLUMN SELECTOR DROP-DOWN MENU */
/* inspired by http://koen.kivits.com/articles/pure-css-menu/ */

.icon {
display: inline-block;
width: 1em;
height: 1em;
fill: currentColor;
}

.icon-menu3 {
width: 1.375em;
}

.ColumnSelector {
position: relative;
}

.LftActionCell .ColumnSelector {
float: left;
}

.RtActionCell .ColumnSelector {
float: right;
}

.ColumnSelector:hover .ColumnSelectorMenu {
visibility: visible;
}

.ColumnSelectorMenu {
position: absolute;
z-index: 1;
visibility: hidden;
transition: visibility .5s;
background-color: #414b5e;
margin-top: 1.5em;
padding: .8em;
}

.LftActionCell .ColumnSelectorMenu {
left: -10px;
}

.RtActionCell .ColumnSelectorMenu {
right: -6px;
}

/* menu pointer */
.ColumnSelectorMenu:before {
content: "";
width: 0;
height: 0;
border-bottom: 10px solid #414b5e;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
position: absolute;
top: -10px;
}

.LftActionCell .ColumnSelectorMenu:before {
left: 5px;
}

.RtActionCell .ColumnSelectorMenu:before {
right: 8px;
}

.ColumnSelectorMenu li {
list-style-type: disc;
margin-left: 1.2em;
white-space: nowrap;
line-height: 1.3em;
}

.ColumnSelectorMenu a {
color: inherit;
cursor: pointer;
}

.ColumnSelectorMenu li.omit {
list-style-type: circle;
}

.ColumnSelectorMenu li.omit a {
color: #999da6;
}

.ColumnSelectorMenu li.omit a:hover {
color: inherit;
}

.ColumnSelectorMenu a:hover {
text-decoration: underline;
}


/* ACTION LIST */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<webobject name = "IsShowColumnSelector">
<div class = "ColumnSelector">
<svg class = "icon icon-menu3" xmlns = "http://www.w3.org/2000/svg" xmlns:xlink = "http://www.w3.org/1999/xlink" viewBox = "0 0 1408 1024">
<title><webobject name = "ColumnSelectorLabel"/></title>
<path class = "path1" d = "M0 192h896v192h-896v-192zM0 448h896v192h-896v-192zM0 704h896v192h-896v-192z" />
<path class = "path2" d = "M992 448l192 192 192-192z" />
</svg>
<ul class = "ColumnSelectorMenu">
<webobject name = "SectionRepetition">
<webobject name = "ColumnLabelRepetition">
<webobject name = "Property">
<webobject name = "ToggleColumnVisibility"><webobject name = "PropertyName" /></webobject>
</webobject>
</webobject>
</webobject>
</ul>
</div>
</webobject>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
IsShowColumnSelector : WOConditional {
condition = isShowColumnSelector;
}

ColumnSelectorLabel : ERXLocalizedString {
value = "ERMD.columnSelectorTitle";
}

SectionRepetition: ERXWORepetition {
list = sectionsContents;
item = currentSection;
}

ColumnLabelRepetition: WORepetition {
_unroll = true;
item = propertyKey;
list = currentSectionKeys;
}

Property : WOGenericContainer {
elementName = "li";
class = columnSelectorClass;
}

ToggleColumnVisibility : AjaxUpdateLink {
updateContainerID = ^updateContainerID;
action = toggleColumnVisibility;
}

PropertyName : WOString {
value = displayNameForProperty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"WebObjects Release" = "WebObjects 5.0";
encoding = "UTF-8";
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<webobject name = "ObjectTable">
<webobject name = "ObjectsRepetition">
<webobject name = "ObjectsRepetition">
<webobject name = "IsRenderTableHeader">
<webobject name = "ObjectTableHeaderRow">
<webobject name = "HasLeftActionsConditional"><th class="ActionCell LftActionCell">&nbsp;</th></webobject>
<webobject name = "HasLeftActionsConditional"><th class="ActionCell LftActionCell"><webobject name = "HasNoRightActionsConditional"><webobject name = "ColumnSelector"/></webobject>&nbsp;</th></webobject>
<webobject name = "SectionRepetition">
<webobject name = "ColumnLabelRepetition">
<webobject name = "IsNotOmitted">
Expand All @@ -12,7 +12,7 @@
</webobject>
</webobject>
</webobject>
<webobject name = "HasRightActionsConditional"><th class="ActionCell RtActionCell">&nbsp;</th></webobject>
<webobject name = "HasRightActionsConditional"><th class="ActionCell RtActionCell"><webobject name = "ColumnSelector"/>&nbsp;</th></webobject>
</webobject>
</webobject>
<webobject name = "ListTableRow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,19 @@ HasLeftActionsConditional : WOConditional {
condition = hasLeftActions;
}

HasNoRightActionsConditional : WOConditional {
condition = hasRightActions;
negate = true;
}

HasRightActionsConditional : WOConditional {
condition = hasRightActions;
}

ColumnSelector : ERMD2WColumnSelector {
d2wContext = d2wContext;
}

D2wContextEntityName : WOString {
value = d2wContext.entity.name;
}
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 539d18c

Please sign in to comment.