Merge branch 'open-master' into open962

Merge in latest from open-master into topic branch
for WTD-962
This commit is contained in:
Victor Woeltjen
2015-04-10 17:30:03 -07:00
24 changed files with 738 additions and 55 deletions

View File

@@ -108,7 +108,8 @@
"templateUrl": "templates/items/items.html",
"uses": [ "composition" ],
"gestures": [ "drop" ],
"type": "folder"
"type": "folder",
"editable": false
}
],
"components": [

View File

@@ -45,7 +45,7 @@
},
{
"key": "properties",
"category": "contextual",
"category": ["contextual", "view-control"],
"implementation": "actions/PropertiesAction.js",
"glyph": "p",
"name": "Edit Properties...",
@@ -79,6 +79,16 @@
"depends": [ "$location" ]
}
],
"policies": [
{
"category": "action",
"implementation": "policies/EditActionPolicy.js"
},
{
"category": "view",
"implementation": "policies/EditableViewPolicy.js"
}
],
"templates": [
{
"key": "edit-library",

View File

@@ -51,6 +51,11 @@ define(
// some special behavior for its context capability.
root = root || domainObject;
// Avoid double-wrapping (WTD-1017)
if (domainObject.hasCapability('editor')) {
return domainObject;
}
// Provide an editable form of the object
return new EditableDomainObject(
domainObject,

View File

@@ -0,0 +1,61 @@
/*global define*/
define(
[],
function () {
"use strict";
/**
* Policy controlling when the `edit` and/or `properties` actions
* can appear as applicable actions of the `view-control` category
* (shown as buttons in the top-right of browse mode.)
* @constructor
*/
function EditActionPolicy() {
// Get a count of views which are not flagged as non-editable.
function countEditableViews(context) {
var domainObject = (context || {}).domainObject,
views = domainObject && domainObject.useCapability('view'),
count = 0;
// A view is editable unless explicitly flagged as not
(views || []).forEach(function (view) {
count += (view.editable !== false) ? 1 : 0;
});
return count;
}
return {
/**
* Check whether or not a given action is allowed by this
* policy.
* @param {Action} action the action
* @param context the context
* @returns {boolean} true if not disallowed
*/
allow: function (action, context) {
var key = action.getMetadata().key,
category = (context || {}).category;
// Only worry about actions in the view-control category
if (category === 'view-control') {
// Restrict 'edit' to cases where there are editable
// views (similarly, restrict 'properties' to when
// the converse is true)
if (key === 'edit') {
return countEditableViews(context) > 0;
} else if (key === 'properties') {
return countEditableViews(context) < 1;
}
}
// Like all policies, allow by default.
return true;
}
};
}
return EditActionPolicy;
}
);

View File

@@ -0,0 +1,36 @@
/*global define*/
define(
[],
function () {
"use strict";
/**
* Policy controlling which views should be visible in Edit mode.
* @constructor
*/
function EditableViewPolicy() {
return {
/**
* Check whether or not a given action is allowed by this
* policy.
* @param {Action} action the action
* @param domainObject the domain object which will be viewed
* @returns {boolean} true if not disallowed
*/
allow: function (view, domainObject) {
// If a view is flagged as non-editable, only allow it
// while we're not in Edit mode.
if ((view || {}).editable === false) {
return !domainObject.hasCapability('editor');
}
// Like all policies, allow by default.
return true;
}
};
}
return EditableViewPolicy;
}
);

View File

@@ -25,7 +25,7 @@ define(
);
mockObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
[ "getId", "getModel", "getCapability", "hasCapability" ]
);
mockCapability = jasmine.createSpyObj(
"capability",

View File

@@ -21,6 +21,9 @@ define(
getModel: function () { return {}; },
getCapability: function (name) {
return completionCapability;
},
hasCapability: function (name) {
return false;
}
};
}
@@ -29,6 +32,9 @@ define(
var result = Object.create(domainObject);
result.wrapped = true;
result.wrappedModel = model;
result.hasCapability = function (name) {
return name === 'editor';
};
captured.wraps = (captured.wraps || 0) + 1;
return result;
}
@@ -112,6 +118,19 @@ define(
expect(cache.isRoot(domainObjects[2])).toBeFalsy();
});
it("does not double-wrap objects", function () {
var domainObject = new TestObject('test-id'),
wrappedObject = cache.getEditableObject(domainObject);
// Same instance should be returned if you try to wrap
// twice. This is necessary, since it's possible to (e.g.)
// use a context capability on an object retrieved via
// composition, in which case a result will already be
// wrapped.
expect(cache.getEditableObject(wrappedObject))
.toBe(wrappedObject);
});
});
}

View File

@@ -0,0 +1,78 @@
/*global define,describe,it,expect,beforeEach,jasmine*/
define(
["../../src/policies/EditActionPolicy"],
function (EditActionPolicy) {
"use strict";
describe("The Edit action policy", function () {
var editableView,
nonEditableView,
undefinedView,
testViews,
testContext,
mockDomainObject,
mockEditAction,
mockPropertiesAction,
policy;
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'useCapability' ]
);
mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']);
mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']);
editableView = { editable: true };
nonEditableView = { editable: false };
undefinedView = { someKey: "some value" };
testViews = [];
mockDomainObject.useCapability.andCallFake(function (c) {
// Provide test views, only for the view capability
return c === 'view' && testViews;
});
mockEditAction.getMetadata.andReturn({ key: 'edit' });
mockPropertiesAction.getMetadata.andReturn({ key: 'properties' });
testContext = {
domainObject: mockDomainObject,
category: 'view-control'
};
policy = new EditActionPolicy();
});
it("allows the edit action when there are editable views", function () {
testViews = [ editableView ];
expect(policy.allow(mockEditAction, testContext)).toBeTruthy();
// No edit flag defined; should be treated as editable
testViews = [ undefinedView, undefinedView ];
expect(policy.allow(mockEditAction, testContext)).toBeTruthy();
});
it("allows the edit properties action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
expect(policy.allow(mockPropertiesAction, testContext)).toBeTruthy();
});
it("disallows the edit action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
expect(policy.allow(mockEditAction, testContext)).toBeFalsy();
});
it("disallows the edit properties action when there are editable views", function () {
testViews = [ editableView ];
expect(policy.allow(mockPropertiesAction, testContext)).toBeFalsy();
});
it("allows the edit properties outside of the 'view-control' category", function () {
testViews = [ nonEditableView ];
testContext.category = "something-else";
expect(policy.allow(mockPropertiesAction, testContext)).toBeTruthy();
});
});
}
);

View File

@@ -0,0 +1,56 @@
/*global define,describe,it,expect,beforeEach,jasmine*/
define(
["../../src/policies/EditableViewPolicy"],
function (EditableViewPolicy) {
"use strict";
describe("The editable view policy", function () {
var testView,
mockDomainObject,
testMode,
policy;
beforeEach(function () {
testMode = true; // Act as if we're in Edit mode by default
mockDomainObject = jasmine.createSpyObj(
'domainObject',
['hasCapability']
);
mockDomainObject.hasCapability.andCallFake(function (c) {
return (c === 'editor') && testMode;
});
policy = new EditableViewPolicy();
});
it("disallows views in edit mode that are flagged as non-editable", function () {
expect(policy.allow({ editable: false }, mockDomainObject))
.toBeFalsy();
});
it("allows views in edit mode that are flagged as editable", function () {
expect(policy.allow({ editable: true }, mockDomainObject))
.toBeTruthy();
});
it("allows any view outside of edit mode", function () {
var testViews = [
{ editable: false },
{ editable: true },
{ someKey: "some value" }
];
testMode = false; // Act as if we're not in Edit mode
testViews.forEach(function (testView) {
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
});
});
it("treats views with no defined 'editable' property as editable", function () {
expect(policy.allow({ someKey: "some value" }, mockDomainObject))
.toBeTruthy();
});
});
}
);

View File

@@ -18,6 +18,8 @@
"objects/EditableDomainObject",
"objects/EditableDomainObjectCache",
"objects/EditableModelCache",
"policies/EditableViewPolicy",
"policies/EditActionPolicy",
"representers/EditRepresenter",
"representers/EditToolbar",
"representers/EditToolbarRepresenter",

View File

@@ -1,5 +1,5 @@
/* CONSTANTS */
/* line 17, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 17, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
@@ -20,38 +20,38 @@ time, mark, audio, video {
font-size: 100%;
vertical-align: baseline; }
/* line 22, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 22, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
html {
line-height: 1; }
/* line 24, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 24, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
ol, ul {
list-style: none; }
/* line 26, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 26, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
table {
border-collapse: collapse;
border-spacing: 0; }
/* line 28, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 28, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
caption, th, td {
text-align: left;
font-weight: normal;
vertical-align: middle; }
/* line 30, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 30, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
q, blockquote {
quotes: none; }
/* line 103, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 103, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
q:before, q:after, blockquote:before, blockquote:after {
content: "";
content: none; }
/* line 32, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 32, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
a img {
border: none; }
/* line 116, ../../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
/* line 116, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {
display: block; }
@@ -302,68 +302,80 @@ span {
min-width: 250px;
width: 48.5%; }
/* line 127, ../sass/user-environ/_layout.scss */
.cols.cols-2-ff .col-100px {
width: 100px; }
/* line 134, ../sass/user-environ/_layout.scss */
.cols.cols-6 .col-1 {
min-width: 83.33333px;
width: 15.16667%; }
/* line 140, ../sass/user-environ/_layout.scss */
.cols.cols-16 .col-1 {
min-width: 31.25px;
width: 4.75%; }
/* line 130, ../sass/user-environ/_layout.scss */
/* line 143, ../sass/user-environ/_layout.scss */
.cols.cols-16 .col-2 {
min-width: 62.5px;
width: 11%; }
/* line 133, ../sass/user-environ/_layout.scss */
/* line 146, ../sass/user-environ/_layout.scss */
.cols.cols-16 .col-7 {
min-width: 218.75px;
width: 42.25%; }
/* line 139, ../sass/user-environ/_layout.scss */
/* line 152, ../sass/user-environ/_layout.scss */
.cols.cols-32 .col-2 {
min-width: 31.25px;
width: 4.75%; }
/* line 142, ../sass/user-environ/_layout.scss */
/* line 155, ../sass/user-environ/_layout.scss */
.cols.cols-32 .col-15 {
min-width: 234.375px;
width: 45.375%; }
/* line 159, ../sass/user-environ/_layout.scss */
.cols .l-row {
overflow: hidden;
*zoom: 1;
padding: 5px 0; }
/* line 148, ../sass/user-environ/_layout.scss */
/* line 165, ../sass/user-environ/_layout.scss */
.pane {
position: absolute; }
/* line 151, ../sass/user-environ/_layout.scss */
/* line 168, ../sass/user-environ/_layout.scss */
.pane.treeview .create-btn-holder {
bottom: auto;
height: 35px; }
/* line 154, ../sass/user-environ/_layout.scss */
/* line 171, ../sass/user-environ/_layout.scss */
.pane.treeview .tree-holder {
overflow: auto;
top: 40px; }
/* line 163, ../sass/user-environ/_layout.scss */
/* line 180, ../sass/user-environ/_layout.scss */
.pane.items .object-holder {
top: 40px; }
/* line 168, ../sass/user-environ/_layout.scss */
/* line 185, ../sass/user-environ/_layout.scss */
.pane.edit-main .object-holder {
top: 0; }
/* line 174, ../sass/user-environ/_layout.scss */
/* line 191, ../sass/user-environ/_layout.scss */
.pane .object-holder {
overflow: auto; }
/* line 182, ../sass/user-environ/_layout.scss */
/* line 199, ../sass/user-environ/_layout.scss */
.split-layout.horizontal > .pane {
margin-top: 5px; }
/* line 185, ../sass/user-environ/_layout.scss */
/* line 202, ../sass/user-environ/_layout.scss */
.split-layout.horizontal > .pane:first-child {
margin-top: 0; }
/* line 192, ../sass/user-environ/_layout.scss */
/* line 209, ../sass/user-environ/_layout.scss */
.split-layout.vertical > .pane {
margin-left: 5px; }
/* line 194, ../sass/user-environ/_layout.scss */
/* line 211, ../sass/user-environ/_layout.scss */
.split-layout.vertical > .pane > .holder {
left: 0;
right: 0; }
/* line 198, ../sass/user-environ/_layout.scss */
/* line 215, ../sass/user-environ/_layout.scss */
.split-layout.vertical > .pane:first-child {
margin-left: 0; }
/* line 200, ../sass/user-environ/_layout.scss */
/* line 217, ../sass/user-environ/_layout.scss */
.split-layout.vertical > .pane:first-child .holder {
right: 5px; }
/* line 209, ../sass/user-environ/_layout.scss */
/* line 226, ../sass/user-environ/_layout.scss */
.vscroll {
overflow-y: auto; }
@@ -2821,10 +2833,10 @@ input[type="text"] {
.wait-spinner {
display: block;
position: absolute;
-webkit-animation: rotation 0.6s infinite linear;
-moz-animation: rotation 0.6s infinite linear;
-o-animation: rotation 0.6s infinite linear;
animation: rotation 0.6s infinite linear;
-webkit-animation: rotation .6s infinite linear;
-moz-animation: rotation .6s infinite linear;
-o-animation: rotation .6s infinite linear;
animation: rotation .6s infinite linear;
border-color: rgba(0, 153, 204, 0.25);
border-top-color: #0099cc;
border-style: solid;
@@ -2863,10 +2875,10 @@ input[type="text"] {
.treeview .wait-spinner {
display: block;
position: absolute;
-webkit-animation: rotation 0.6s infinite linear;
-moz-animation: rotation 0.6s infinite linear;
-o-animation: rotation 0.6s infinite linear;
animation: rotation 0.6s infinite linear;
-webkit-animation: rotation .6s infinite linear;
-moz-animation: rotation .6s infinite linear;
-o-animation: rotation .6s infinite linear;
animation: rotation .6s infinite linear;
border-color: rgba(0, 153, 204, 0.25);
border-top-color: #0099cc;
border-style: solid;
@@ -2879,6 +2891,18 @@ input[type="text"] {
top: 2px;
left: 0; }
/* Classes to be used for lists of properties and values */
/* line 4, ../sass/_properties.scss */
.properties .s-row {
border-top: 1px solid #4d4d4d;
font-size: 0.8em; }
/* line 7, ../sass/_properties.scss */
.properties .s-row:first-child {
border: none; }
/* line 10, ../sass/_properties.scss */
.properties .s-row .s-value {
color: #fff; }
/* line 1, ../sass/_autoflow.scss */
.autoflow {
font-size: 0.75rem; }

View File

@@ -37,4 +37,5 @@
@import "helpers/bubbles";
@import "helpers/splitter";
@import "helpers/wait-spinner";
@import "properties";
@import "autoflow";

View File

@@ -0,0 +1,14 @@
/* Classes to be used for lists of properties and values */
.properties {
.s-row {
border-top: 1px solid $colorInteriorBorder;
font-size: 0.8em;
&:first-child {
border: none;
}
.s-value {
color: #fff;
}
}
}

View File

@@ -122,6 +122,19 @@
@include cols($nc, 1);
}
}
&.cols-2-ff {
// 2 columns, first column is fixed, second is fluid
.col-100px {
width: 100px;
}
}
&.cols-6 {
$nc: 6;
.col-1 {
@include cols($nc, 1);
}
}
&.cols-16 {
$nc: 16;
.col-1 {
@@ -143,6 +156,10 @@
@include cols($nc, 15);
}
}
.l-row {
@include clearfix;
padding: $interiorMargin 0;
}
}
.pane {