Skip to content

Commit

Permalink
Start refactor form controller
Browse files Browse the repository at this point in the history
  • Loading branch information
toalina committed Oct 15, 2015
1 parent df87c5f commit 7a5064a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions gulp/tasks/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ var config = require('../config');
gulp.task('watch', function() {
gulp.watch(config.javascript.src, ['webpack']);
gulp.watch(config.sass.src, ['sass']);
gulp.watch(config.sass.src, ['index']);
gulp.watch(config.sass.src, ['html']);
gulp.watch(config.index.src, ['index']);
gulp.watch(config.html.src, ['html']);

gulp.watch(['./node_modules/angular/angular.js', './node_modules/angular-route/angular-route.js']);
// Watchify will watch and recompile our JS, so no need to gulp.watch it
Expand Down
3 changes: 1 addition & 2 deletions src/js/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ require("./gist-service.js");
require("./gists-ctrl.js");
require("./gists-filters.js");

// require("./gist-form-ctrl.js");
// require("./gistlist-ctrl.js");
require("./gist-form-ctrl.js");
require("./single-gist-ctrl.js");

// require("./gist-date-ctrl.js");
44 changes: 22 additions & 22 deletions src/js/gist-form-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,34 @@ require("./gists-app.js");
function start() {

vm.gist.created_at = new Date(Date.now());
if ($routeParams.gist_id) {
BlogpostService.get($routeParams.gist_id).then(function (resp) {
if ($routeParams.id) {
BlogpostService.get($routeParams.id).then(function (resp) {

vm.gist = resp.data;
vm.gist.created_at = vm.gist.created_at || new Date(Date.now());
});
}
}

function successHandler(response) {
vm.gist = response.data;
vm.newFilename = Object.keys(vm.gist.files)[0];
vm.newContent = vm.gist.files[vm.newFilename].content;

$log.info("response", response);
$log.info(vm.gist);
}

function errorHandler (response) {
$log.error("response", response);
} if ($routeParams.gist_id) {
GistService.get($routeParams.gist_id).then(function()

)
}
}


function saveGist () {

var method;
Expand Down Expand Up @@ -55,26 +74,7 @@ require("./gists-app.js");
}
}]);

}());


/// success/error handler for saveGist function

function successHandler(response) {
vm.gist = response.data;
vm.newFilename = Object.keys(vm.gist.files)[0];
vm.newContent = vm.gist.files[vm.newFilename].content;
}()); // ======= END OF IIFE =======//

$log.info("response", response);
$log.info(vm.gist);
}

function errorHandler (response) {
$log.error("response", response);
}
if ($routeParams.gist_id) {
GistService.get($routeParams.gist_id).then(function()

)
}
}

0 comments on commit 7a5064a

Please sign in to comment.