Skip to content

Commit

Permalink
Merge d00b8f8 into 130a184
Browse files Browse the repository at this point in the history
  • Loading branch information
trepagnier committed Nov 1, 2018
2 parents 130a184 + d00b8f8 commit 1818bb1
Show file tree
Hide file tree
Showing 15 changed files with 585 additions and 507 deletions.
54 changes: 54 additions & 0 deletions mapstory/static/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {}
},
"env": {
"browser": true,
"node": true,
"jasmine": true,
"protractor": true,
"es6": true
},
"extends": ["airbnb-base", "prettier"],
"globals": {
"ol": true,
"storytools": true,
"angular": true,
"inject": true,
"toastr": true,
"goog": true
},
"plugins": [
"import",
"prettier"
],
"rules": {
"camelcase": ["error", {
"properties": "always"
}],
"import/extensions": "off",
"import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off",
"indent": ["error", 2],
"no-bitwise": ["error", {
"int32Hint": true
}],
"no-param-reassign": "off",
"no-plusplus": ["error", {
"allowForLoopAfterthoughts": true
}],
"no-unused-vars": ["error", {
"args": "none"
}],
"one-var": "off",
"prefer-destructuring": "off",
"prettier/prettier": "off",
"quotes": ["error", "double", {
"allowTemplateLiterals": true,
"avoidEscape": true
}]
}
}
67 changes: 26 additions & 41 deletions mapstory/static/mapstory/js/src/collection.controller.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
/*
* Collections Controller
*/
(function() {


angular
.module('mapstory')
.controller('collectionController', collectionController);

(() => {
function collectionController($http, $scope) {
$scope.query = function(group_id) {
$http.get('/api/collections/').then((response) => {
$scope.query = groupId => {
$http.get("/api/collections/").then(response => {
// Determine which collection this is by using the group id
const collections = response.data.objects;
let data;
for (var i = 0; i < collections.length; i++) {
if (collections[i].group.id == group_id) {
for (let i = 0; i < collections.length; i++) {
if (collections[i].group.id === groupId) {
data = collections[i];
}
}
Expand All @@ -24,8 +18,8 @@
document.title = $scope.title;
$scope.slug = data.group.slug;
// grab only the media names
$scope.facebook = data.group.social_facebook.split('/')[1];
$scope.twitter = data.group.social_twitter.split('/')[1];
$scope.facebook = data.group.social_facebook.split("/")[1];
$scope.twitter = data.group.social_twitter.split("/")[1];
$scope.tasks = data.group.tasks;
$scope.interests = data.group.keywords;
$scope.summary = data.group.description;
Expand All @@ -34,51 +28,42 @@
// MapStories and StoryLayers need to separated because they are held together in the resources
$scope.layers = [];
$scope.maps = [];
for (var i = 0; i < data.resources.length; i++) {
const resource_type = data.resources[i].detail_url.split('/')[1];
if (resource_type == 'layers') {
for (let i = 0; i < data.resources.length; i += 1) {
const resourceType = data.resources[i].detail_url.split("/")[1];
if (resourceType === "layers") {
$scope.layers.push(data.resources[i]);
} else if (resource_type == 'maps') {
} else if (resourceType === "maps") {
$scope.maps.push(data.resources[i]);
}
}
$scope.storytellers = data.users;

// Create api query
let api_query = '/api/base/?owner__username__in=';
for (var i = 0; i < data.users.length; i++) {
api_query += `${data.users[i].username },`;
let apiQuery = "/api/base/?owner__username__in=";
for (let i = 0; i < data.users.length; i++) {
apiQuery += `${data.users[i].username},`;
}
// For organizations, need to grab the MapStories and StoryLayers created by all its users
$scope.org_layers = [];
$scope.org_maps = [];
$http.get(api_query).then((response) => {
const results = response.data.objects;
$scope.orgLayers = [];
$scope.orgMaps = [];
$http.get(apiQuery).then(res => {
const results = res.data.objects;
for (let i = 0; i < results.length; i++) {
if (results[i].detail_url) {
// Checks the type if it's a layer or map
if (results[i].detail_url.indexOf('layers') > -1) {
$scope.org_layers.push(results[i]);
if (results[i].detail_url.indexOf("layers") > -1) {
$scope.orgLayers.push(results[i]);
} else {
$scope.org_maps.push(results[i]);
$scope.orgMaps.push(results[i]);
}
}
}
});

const keywords_list = data.group.keywords;

// var MAX_TOKENS = 10;
// $('#tokenfield-interests').val(keywords_list);
// $('#tokenfield-interests').tokenfield({
// limit: MAX_TOKENS
// });
// $('#tokenfield-interests').tokenfield('readonly');
// $('.token-label').click(function(e) {
// var tag = $(e.target).text();
// window.location.href = '/search/?limit=100&offset=0&keywords__slug__in=' + tag;
// });
});
};
}
})();

angular
.module("mapstory")
.controller("collectionController", collectionController);
})();

0 comments on commit 1818bb1

Please sign in to comment.