DocumentsController refactoring

This commit is contained in:
tmshv committed 2016-02-22 01:20:31 +03:00
1 parent e06742daea
commit 59e99769eb
3 files changed
+12 -54

No files matched your search

+2 -1
View File
@@ -7,6 +7,7 @@ import Award from './components/Award';
import GalleryItem from './components/GalleryItem';
import TeamMemberProfile from './components/TeamMemberProfile';
import AppController from './controllers/AppController';
import DocumentsController from './controllers/DocumentsController';
import api from './api/api';
let deps = [
@@ -98,7 +99,6 @@ app.run(($location, $rootScope, $http) => {
require('./pages/schedule'),
require('./pages/team'),
require('./pages/gallery'),
require('./pages/docs'),
require('./controllers/ContactsController'),
require('./controllers/CopyrightController'),
Document,
@@ -106,6 +106,7 @@ app.run(($location, $rootScope, $http) => {
GalleryItem,
TeamMemberProfile,
AppController,
DocumentsController,
function (app) {
app.controller('SchedulePageController', ($scope) => {
$scope.pageClass = 'page-schedule';
@@ -0,0 +1,10 @@
export default function (app) {
app.controller('DocumentsController', ($scope, api, docs) => {
$scope.documents = docs.docs;
api.document.awards()
.success(data => {
$scope.awards = data;
});
});
};
-53
View File
@@ -1,53 +0,0 @@
module.exports = function (app) {
app.controller("DocumentsController", function ($scope, api, docs) {
$scope.documents = docs.docs;
api.document.awards()
.success(data => {
$scope.awards = data;
});
});
};
/**
* Generates list of numbers
* @param {Number} start starting value
* @param {Number} num amount of numbers in list
* @param {Number} step difference value
* @return {Array} list of numbers
*/
function range(start, num, step) {
var list = [];
var val = start;
for (var i = 0; i < num; i++) {
list.push(val);
val += step;
}
return list;
}
///**
// * Monday date of current week
// * @param {[type]} d [description]
// * @return {[type]} [description]
// */
//function getMonday(d) {
// d = new Date(d);
// var day = d.getDay();
// var diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday
// return new Date(d.setDate(diff));
//}
function getDates(day) {
var dates = [];
var prev = day == 0 ? 0 : day - 1;
var next = 6 - prev;
var dayMask = range(-1, prev, -1).concat([0]).concat(range(1, next, 1));
dayMask.forEach(function (m) {
var time = Date.now() + (1000 * 60 * 60 * 24) * m;
var date = new Date(time);
dates.push(date.getDate());
});
return dates;
}