Edit mode button works

This commit is contained in:
Henry 2015-10-21 17:31:04 -07:00
parent 9925b91405
commit 5013646e89
4 changed files with 25 additions and 17 deletions

View File

@ -35,7 +35,8 @@
{
"key": "BrowseObjectController",
"implementation": "BrowseObjectController.js",
"depends": [ "$scope", "$location", "$route", "$q" ]
"depends": [ "$scope", "$location", "$route", "$q",
"navigationService" ]
},
{
"key": "CreateMenuController",

View File

@ -20,9 +20,10 @@
at runtime from the About dialog for additional information.
-->
<div ng-init="
editBtns = [{ cssclass: 'save',title: 'Save' },{ cssclass: 'cancel',title: 'Discard Changes' }];
editBtns = [{ cssclass: 'save',title: 'Save' },{ cssclass: 'cancel',title: 'Discard Changes', action:'cancelEditing' }];
"></div>
<span ng-controller="BrowseObjectController">
<span ng-controller="BrowseObjectController"
mct-before-unload="getUnloadWarning()">
<a class="s-btn"
style="opacity: 0.9; position:absolute; right: 250px; z-index: 100"
ng-class="{ major:!editMode }"
@ -100,7 +101,7 @@
<span ng-repeat="btn in editBtns">
<a class='s-btn t-{{btn.cssclass}}'
title='{{btn.title}}'
ng-click="currentAction.perform()"
ng-click="doAction(btn.action)"
ng-class="{ major: $index === 0 }">
<span class="title-label">{{btn.title}}</span>
</a>

View File

@ -33,7 +33,8 @@ define(
* @memberof platform/commonUI/browse
* @constructor
*/
function BrowseObjectController($scope, $location, $route, $q) {
function BrowseObjectController($scope, $location, $route, $q, navigationService) {
var navigatedObject;
function setViewForDomainObject(domainObject) {
var locationViewKey = $location.search().view;
@ -50,7 +51,7 @@ define(
.forEach(selectViewIfMatching);
}
$scope.editMode = domainObject.getDomainObject ? true : false;
console.log("edit mode set to " + $scope.editMode);
navigatedObject = domainObject;
}
function updateQueryParam(viewKey) {
@ -72,11 +73,13 @@ define(
$scope.$watch('domainObject', setViewForDomainObject);
$scope.$watch('representation.selected.key', updateQueryParam);
/* $scope.$on(GestureConstants.MCT_DROP_EVENT, function() {
console.log("Edit mode changed");
$scope.editMode = true;
}); */
console.log("Controller loaded");
$scope.cancelEditing = function() {
navigationService.setNavigation($scope.domainObject.getDomainObject());
}
$scope.doAction = function (action){
$scope[action] && $scope[action]();
}
}

View File

@ -25,8 +25,8 @@
* Module defining EditAction. Created by vwoeltje on 11/14/14.
*/
define(
[],
function () {
['../objects/EditableDomainObject'],
function (EditableDomainObject) {
"use strict";
// A no-op action to return in the event that the action cannot
@ -71,8 +71,10 @@ define(
* Enter edit mode.
*/
EditAction.prototype.perform = function () {
this.navigationService.setNavigation(this.domainObject);
this.$location.path("/edit");
if (!this.domainObject.getDomainObject) {
this.navigationService.setNavigation(new EditableDomainObject(this.domainObject));
}
//this.$location.path("/edit");
};
/**
@ -83,10 +85,11 @@ define(
*/
EditAction.appliesTo = function (context) {
var domainObject = (context || {}).domainObject,
type = domainObject && domainObject.getCapability('type');
type = domainObject && domainObject.getCapability('type'),
isEditMode = domainObject && domainObject.getDomainObject ? true : false;
// Only allow creatable types to be edited
return type && type.hasFeature('creation');
return type && type.hasFeature('creation') && !isEditMode;
};
return EditAction;