Skip to content

Commit

Permalink
Started with edit text
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasselgren committed Aug 12, 2014
1 parent b197f00 commit 1511950
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 17 deletions.
16 changes: 10 additions & 6 deletions app/js/controller/ActivitiesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval

$scope.modified = false;

$scope.save = function(){
Data.saveActivity().success(function(){
$scope.modified = false;
});
}

if($.isEmptyObject(Data.currentActivity)){
$location.path('/');
return;
Expand Down Expand Up @@ -49,12 +55,11 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval
console.log("data.currentActivity.description changed");
$scope.modified = true;
console.log("modified = true");
},5000);
},1000);
};
});

$scope.$watch('data.currentActivity.shortDescription', function(newVal, oldVal){

if(newVal != oldVal){
if(timeout){
$timeout.cancel(timeout);
Expand All @@ -64,7 +69,7 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval
console.log("data.currentActivity.shortDescription changed");
$scope.modified = true;
console.log("modified = true");
},5000);
},1000);
};
});

Expand All @@ -76,7 +81,6 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval

$scope.editThing = function(thing){
var index = $scope.data.activity.things.indexOf(thing);

$location.path('/activity/edit/thing/' + index)

};
Expand All @@ -97,7 +101,7 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval
$scope.createThingCompleted = function(){
$scope.createThing = false;
$scope.editThing = false;
}
};

$scope.cancelCreateThing = function(){
$scope.createThing = false;
Expand All @@ -113,4 +117,4 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval
};

init();
});
});
40 changes: 40 additions & 0 deletions app/js/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,46 @@ app.directive("text", function(){
restrict: "A",
require: "thing",
templateUrl: "views/directive/thing_text.html",
link: function(scope, element, attrs, thingController){

scope.controll = {edit: false};

scope.deleteThing = function(thing){
thingController.deleteThing(thing);
}

scope.changeEdit = function(){
scope.controll.edit = !scope.controll.edit
};

scope.editMode = function(){
return scope.controll.edit;
};

scope.save = function(){
thingController.save().success(function(data){
scope.controll.edit = false;
});
}

scope.deleteThing = function(thing){
thingController.deleteThing(thing);
}

scope.cancel = function(){
scope.controll.edit = false;
};

scope.filePath = function(fileId){
var activityId = thingController.activityId;
var backEndAdress = thingController.backEndAdress;
if(fileId && activityId){
return backEndAdress + '/file/download/'+activityId+'/'+fileId;
}

return "";
};
}
}
});

Expand Down
17 changes: 10 additions & 7 deletions app/views/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
<div class="navbar-header">
<a href="#" class="navbar-brand">Home</a>
<a href class="navbar-brand" ng-click="startCreateThing()">Create new thing</a>
<a href class="navbar-brand" ng-show="modified">Save</a>
<a href class="navbar-brand" ng-click="save()" ng-show="modified">Save</a>
</div>
</div>
</div>

<div class="header vert">
<div class="container">
<h1>{{ data.currentActivity.name }}</h1>
<p class="lead" ng-click="editShortDescr = !editShortDescr" ng-show="!editShortDescr">{{ data.currentActivity.shortDescription }}</p>
<p class="lead" ng-dblclick="editShortDescr = !editShortDescr" ng-show="!editShortDescr">{{ data.currentActivity.shortDescription }}</p>
<p class="lead" ng-show="editShortDescr">
<input class="form-control" ng-blur="editShortDescr = false" ng-model="data.currentActivity.shortDescription">
</p>
<div>&nbsp;</div>
<a ng-click="startCreateThing()" class="btn btn-default btn-lg">Create new thing</a>
<a href class="btn btn-default btn-lg" ng-click="save()" ng-show="modified">Save</a>
</div>
</div>

Expand All @@ -27,8 +28,8 @@ <h1>{{ data.currentActivity.name }}</h1>
<div class="container">
<div class="row">
<div class="col-xs-12 text-center">
<h1 ng-click="editOverview = !editOverview">Overview</h1>
<p class="lead" ng-click="editOverview = !editOverview" ng-show="!editOverview">{{ data.currentActivity.description }}</p>
<h1 ng-dblclick="editOverview = !editOverview">Overview</h1>
<p class="lead" ng-dblclick="editOverview = !editOverview" ng-show="!editOverview">{{ data.currentActivity.description }}</p>
<p class="lead" ng-show="editOverview">
<input class="form-control" ng-blur="editOverview=false" ng-model="data.currentActivity.description">
</p>
Expand All @@ -46,7 +47,7 @@ <h1 ng-click="editOverview = !editOverview">Overview</h1>


<div>
<div class="blurb" id="sec4">
<div class="blurb" id="sec4" ng-if="(data.currentActivity.things | filter: {type: 'TODO', completed: false}).length > 0">
<div class="container">
<div class="row">
<div class="col-xs-12">
Expand Down Expand Up @@ -107,13 +108,15 @@ <h2 ng-click="thing.completed = !thing.completed" style="cursor: pointer;">

<hr>

<div class="blurb" id="sec4">
<div class="blurb" id="sec4" ng-if="(data.currentActivity.things | filter: {type: 'TODO', completed: true}).length > 0">


<div class="container">
<div class="row">
<div class="col-xs-12">
<h1 class="text-center">This is what I have done</h1>
<div class="col-xs-8 col-xs-offset-2">
<div ng-repeat="thing in data.currentActivity.things | filter: {type: 'TODO', completed: true}" class="row">
<div ng-repeat="thing in filterdItems = (data.currentActivity.things | filter: {type: 'TODO', completed: true})" class="row">
<div class="col-xs-12">
<h2 ng-click="thing.completed = !thing.completed" style="cursor: pointer;">
<i class="fa fa-check-square-o"></i>
Expand Down
41 changes: 37 additions & 4 deletions app/views/directive/thing_text.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div ng-if="thing.type == 'TEXT'" class="featurette" id="sec2">
<div class="container">
<div class="row">
<div class="pull-right">
<a href ng-click="editThing(thing)"><i class="fa fa-pencil"></i></a> | <a href><i class="fa fa-trash-o"></i></a>
<div ng-show="!editMode()" class="row">
<div class="pull-right">
<a href ng-click="changeEdit()"><i class="fa fa-pencil"></i></a> | <a href ng-click="deleteThing(thing)"><i class="fa fa-trash-o"></i></a>
</div>
<div class="col-xs-1 text-center pull-left">
{{ thing.created | date : 'd'}}<br />
Expand All @@ -29,7 +29,7 @@ <h1>{{ thing.name }}</h1>
<i ng-if="!subThing.completed" class="fa fa-square-o fa-3x"></i>
<i ng-if="subThing.completed" class="fa fa-check-square-o fa-3x"></i>
</span>
<span ng-switch-when="FILE"><i class="fa fa-file-pdf-o fa-3x"></i></span>
<span ng-switch-when="FILE"><a target="_self" ng-href="{{filePath(subThing.fileId)}}" download="subThing.name"><i class="fa fa-file-pdf-o fa-3x"></i></a></span>
</p>
</div>
<div class="panel-footer text-center col-xs-12" ng-show="showDetails">
Expand All @@ -50,5 +50,38 @@ <h1>{{ thing.name }}</h1>
</div>
</div>
</div>
<div ng-show="editMode()" class="row panel panel-default">
<div class="panel-body">

<h1>Edit thing</h1>
<form-input type="text" label="Name" model="thing.name"></form-input>

<div class="form-group">
<text-angular ng-model="thing.text" ta-toolbar="[['h1','h2','h3','h4','p'],['bold','italics', 'underline'],['ul','ol'],['html']]"></text-angular>
</div>
<div class="form-group">
<button class="btn btn-sm btn-info">Add thing</button>
</div>
</div>
<div ng-show="(thing.things | filter: {type: 'FILE'}).length > 0" class="panel-footer">
<h3>Files</h3>
<div ng-repeat="subthing in filteredThings = (thing.things | filter: {type: 'FILE'})">
<h4>{{subthing.name}}</h4>
<p ng-bind-html="subthing.description"></p>
</div>
</div>
<div ng-show="(thing.things | filter: {type: 'TODO'}).length > 0" class="panel-footer">
<h3>ToDo</h3>
<div ng-repeat="subthing in filteredThings = (thing.things | filter: {type: 'TODO'})">
TODO
</div>
</div>
<div class="panel-body">
<div class="form-group">
<button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
<button type="button" class="btn btn-default" ng-click="save()">Save</button>
</div>
</div>
</div>
</div>
</div>

0 comments on commit 1511950

Please sign in to comment.