Skip to content

Commit

Permalink
#41 reminders controller move documentation to each function
Browse files Browse the repository at this point in the history
  • Loading branch information
Pieter-Jan Vandenberghe committed Aug 12, 2016
1 parent 5775be9 commit 0e08de7
Showing 1 changed file with 30 additions and 35 deletions.
65 changes: 30 additions & 35 deletions www/app/reminders/reminders.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
vm.showEdit = false;
vm.enabled = Reminders.isEnabled();

vm.addReminder = addReminder;
vm.editReminder = editReminder;
vm.toggleDelete = toggleDelete;
vm.deleteReminder = deleteReminder;
vm.toggleReminder = toggleReminder;
vm.toggleEnabled = toggleEnabled;

loadReminders();

function loadReminders() {
Reminders.loadReminders().then(function(reminders) {
vm.reminders = reminders;
});
}

/**
* @ngdoc method
* @name addReminder
Expand All @@ -31,7 +46,9 @@
* Opens popup to add a reminder
* See {@link app.reminders.service:RemindersService ReminderService#addReminder()}
*/
vm.addReminder = addReminder;
function addReminder() {
Reminders.addReminder($scope, vm.reminders);
}

/**
* @ngdoc method
Expand All @@ -42,7 +59,9 @@
* See {@link app.reminders.service:RemindersService ReminderService#editReminder()}
* @param {Object} reminder reminder that is to be edited
*/
vm.editReminder = editReminder;
function editReminder(reminder) {
Reminders.editReminder($scope, vm.reminders, reminder);
}

/**
* @ngdoc method
Expand All @@ -51,7 +70,9 @@
* @description
* Toggles display of delete button next to every reminder
*/
vm.toggleDelete = toggleDelete;
function toggleDelete() {
vm.showDelete = !vm.showDelete;
}

/**
* @ngdoc method
Expand All @@ -62,7 +83,9 @@
* See {@link app.reminders.service:RemindersService ReminderService#deleteReminder()}
* @param {Object} reminder reminder that is to be deleted
*/
vm.deleteReminder = deleteReminder;
function deleteReminder(reminder) {
vm.showDelete = Reminders.deleteReminder(reminder, vm.reminders);
}

/**
* @ngdoc method
Expand All @@ -73,7 +96,9 @@
* See {@link app.reminders.service:RemindersService ReminderService#toggleReminder()}
* @param {Object} reminder reminder that is to enabled/disabled
*/
vm.toggleReminder = toggleReminder;
function toggleReminder(reminder) {
Reminders.toggleReminder(reminder, vm.reminders);
}

/**
* @ngdoc method
Expand All @@ -83,36 +108,6 @@
* Toggle whether all reminders are enabled
* See {@link app.reminders.service:RemindersService ReminderService#setEnabled()}
*/
vm.toggleEnabled = toggleEnabled;

loadReminders();

function loadReminders() {
Reminders.loadReminders().then(function(reminders) {
vm.reminders = reminders;
});
}

function addReminder() {
Reminders.addReminder($scope, vm.reminders);
}

function editReminder(reminder) {
Reminders.editReminder($scope, vm.reminders, reminder);
}

function toggleDelete() {
vm.showDelete = !vm.showDelete;
}

function deleteReminder(reminder) {
vm.showDelete = Reminders.deleteReminder(reminder, vm.reminders);
}

function toggleReminder(reminder) {
Reminders.toggleReminder(reminder, vm.reminders);
}

function toggleEnabled() {
vm.enabled = !vm.enabled;
Reminders.setEnabled(vm.enabled, vm.reminders);
Expand Down

0 comments on commit 0e08de7

Please sign in to comment.