Skip to content

Commit

Permalink
implement project.remove, add TODOs for Document service removal
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishokamp committed Sep 22, 2014
1 parent fb01e4d commit 7a2e2d1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 35 deletions.
4 changes: 2 additions & 2 deletions app/scripts/directives/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular.module('directives').directive('toolbar', ['editSession', '$log', '$time
return session.activeSegment;
},
function(index) {
$log.log('ACTIVE SEGMENT CHANGED');
$log.log('toolbar: ACTIVE SEGMENT CHANGED');
$log.log(index);
var above = $('#segment-' + index);
$(above).after(el);
Expand All @@ -24,7 +24,7 @@ angular.module('directives').directive('toolbar', ['editSession', '$log', '$time
$(above).after(el);

$scope.$on('update-glossary-area', function(evt, data) {
$log.log('toolbar heard update-glossary-area');
$log.log('toolbar: update-glossary-area');
$log.log(data);

$scope.glossaryMatches = data.map(function(item) {
Expand Down
16 changes: 0 additions & 16 deletions app/scripts/editArea/contentArea/segmentArea/segmentArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ $scope.clearSelection = function() {
// $scope.insertText(char);
// };
//
// // used as a callback for the glossary
var updateGlossaryArea = function(glossaryMatches) {
if (glossaryMatches) {
// the toolbar should be listening for this
$rootScope.$broadcast('update-glossary-area', glossaryMatches);
}
};
//
//// TODO: collapse (remove from DOM) when this segment goes out of focus
// $scope.isCollapsed = {collapsed: true, clicked: false};
Expand All @@ -150,15 +143,6 @@ $scope.clearSelection = function() {
$scope.$broadcast('clear-editor');
};

// TODO: use a promise
// prep the model
var glossary = {};
glossary.glossaryQuery = undefined;
$scope.glossary = glossary;
$scope.queryGlossary = function(query, fromLang, toLang) {
Glossary.getMatches(query, updateGlossaryArea, fromLang, toLang);
Session.updateStat('queryGlossary', $scope.$index, query);
};

// Informs other segments that they should make a change.
// The event argument is a unique object created by the ruleMap service.
Expand Down
18 changes: 17 additions & 1 deletion app/scripts/editArea/editArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ angular.module('controllers').controller('EditAreaCtrl', ['$scope', '$location',
Document) {

// TODO: move this to a proper global controller for the edit area
// global user options (may be accessed or changed from child controllers
// global user options (may be accessed or changed from child controllers)
$scope.visible = {
toolbar: false
};

$scope.session = session;
// TODO: remove the Document service and set document data directly on this controller
$scope.document = Document;
$scope.url = loggerUrl;

Expand Down Expand Up @@ -106,6 +107,21 @@ angular.module('controllers').controller('EditAreaCtrl', ['$scope', '$location',
$scope.$broadcast('toggleShowInvisibleChars', value);
};

// used as a callback for the glossary
var updateGlossaryArea = function(glossaryMatches) {
if (glossaryMatches) {
// the toolbar should be listening for this
$rootScope.$broadcast('update-glossary-area', glossaryMatches);
}
};

$scope.queryGlossary = function(query, fromLang, toLang) {
Glossary.getMatches(query, updateGlossaryArea, fromLang, toLang);
Session.updateStat('queryGlossary', $scope.$index, query);
};

// Working - use a callback here just like with the glossary
// Working - remove the event listener here - give it to the toolbar
// Concordance
$scope.queryConcordancer = function(query, lang) {
if (!lang)
Expand Down
33 changes: 18 additions & 15 deletions app/scripts/projects/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ angular.module('controllers')

// $scope.projectResource now holds a reference to the $resource
// the Document service will hold the XML content after the doc is parsed by xliffParser
// WORKING - remove the Document service, put its functionality on the EditAreaCtrl
$scope.projectResource = project;
XliffParser.parseXML(project.content);
});
Expand All @@ -25,25 +26,27 @@ angular.module('controllers')
// TODO: the XLIFF data should be stored on the $scope of the ProjectCtrl
// TODO: there should be one ProjectCtrl for each project, and a separate ProjectListCtrl to handle the list of projects

// TODO: implement project.delete and project.update
// $scope.remove = function(blog) {
// blog.$remove();
//
// for (var i in $scope.blogs) {
// TODO: show confirmation modal
$scope.remove = function(project) {
$log.log('Remove project');
project.$remove();

// if ($scope.blogs[i] == blog) {
// $scope.blogs.splice(i, 1);
// }
// }
// };
//
for (var i in $scope.projects) {

if ($scope.projects[i] == project) {
$scope.projects.splice(i, 1);
}
}
};

// TODO: this function should be accessible from project.create
// $scope.update = function() {
// //
// var blog = $scope.blog;
// blog.$update(function() {
// $location.path('blogs/' + blog._id);
// var project = $scope.project;
// project.$update(function() {
// $location.path('projects/' + project._id);
// });
// };
//

}]);

2 changes: 1 addition & 1 deletion app/views/partials/projects/project-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h3>Your Projects</h3>
<div class="btn col-xs-1" ui-sref="projects.edit({projectId: project._id})">
<span class="ion-edit project-icon"></span>
</div>
<div class="btn col-xs-1" ui-sref="projects.edit({projectId: project._id})">
<div class="btn col-xs-1" ng-click="remove(project)">
<span class="ion-close project-icon"></span>
</div>
</div>
Expand Down

0 comments on commit 7a2e2d1

Please sign in to comment.