Skip to content

Commit

Permalink
Merge pull request #138 from matortheeternal/dev
Browse files Browse the repository at this point in the history
Public Beta Hotfix Release v1.0.2
  • Loading branch information
matortheeternal authored Nov 29, 2016
2 parents b11cf69 + 9272cbe commit 115aa3f
Show file tree
Hide file tree
Showing 76 changed files with 1,505 additions and 179 deletions.
29 changes: 29 additions & 0 deletions mod-picker/app/assets/javascripts/BackendAPI/configFilesService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
app.service('configFilesService', function() {
var service = this;

this.groupHasChildren = function(group) {
for (var i = 0; i < group.children.length; i++) {
var child = group.children[i];
if (!child._destroy) return true;
}
return false;
};

this.firstAvailableConfig = function(group) {
return group.children.find(function(child) {
return !child._destroy;
});
};

this.recoverConfigFileGroups = function(model) {
model.forEach(function(group) {
if (group._destroy && service.groupHasChildren(group)) {
delete group._destroy;
if (!group.activeConfig) {
group.activeConfig = service.firstAvailableConfig(group);
group.activeConfig.active = true;
}
}
});
};

this.addConfigFile = function(model, configFile) {
var foundGroup = model.find(function(group) {
return group.id == configFile.config_file.mod.id;
Expand Down Expand Up @@ -43,6 +69,9 @@ app.service('configFilesService', function() {
service.addCustomConfigFile(model, customConfigFile);
});
model.forEach(function(group) {
group.children.sort(function(a, b) {
return a.filename - b.filename;
});
group.activeConfig = group.children[0];
group.activeConfig.active = true;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ app.service('modListService', function(backend, $q, userTitleService, contributi
this.newModListMod = function(mod_list_mod) {
var action = $q.defer();
backend.post('/mod_list_mods', {mod_list_mod: mod_list_mod}).then(function(data) {
modService.associateModImage(data.mod_list_mod.mod);
userTitleService.associateTitles(data.mod_compatibility_notes);
userTitleService.associateTitles(data.plugin_compatibility_notes);
userTitleService.associateTitles(data.install_order_notes);
Expand Down
13 changes: 4 additions & 9 deletions mod-picker/app/assets/javascripts/BackendAPI/modService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app.service('modService', function(backend, $q, pageUtils, objectUtils, contributionService, userTitleService, reviewSectionService, recordGroupService, pluginService, assetUtils) {
app.service('modService', function(backend, $q, pageUtils, objectUtils, contributionService, userTitleService, reviewSectionService, recordGroupService, pluginService, assetUtils, modOptionUtils) {
var service = this;

this.retrieveMods = function(options, pageInformation) {
Expand Down Expand Up @@ -110,20 +110,15 @@ app.service('modService', function(backend, $q, pageUtils, objectUtils, contribu
this.retrieveModAnalysis = function(modId) {
var output = $q.defer();
backend.retrieve('/mods/' + modId + '/' + 'analysis').then(function(analysis) {
// create nestedAssets tree
analysis.nestedAssets = assetUtils.getNestedAssets(analysis.assets);
assetUtils.sortNestedAssets(analysis.nestedAssets);

// prepare plugin data for display
recordGroupService.associateGroups(analysis.plugins);
pluginService.combineAndSortMasters(analysis.plugins);
pluginService.associateOverrides(analysis.plugins);
pluginService.sortErrors(analysis.plugins);

// set default options to active
analysis.mod_options.forEach(function(option) {
option.active = option.default;
});
// create nested mod options tree
modOptionUtils.activateDefaultModOptions(analysis.mod_options);
analysis.nestedOptions = modOptionUtils.getNestedModOptions(analysis.mod_options);

output.resolve(analysis);
}, function(response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ app.service('notificationService', function($q, backend, pageUtils) {
return action.promise;
};

this.retrieveEvents = function(options, pageInformation) {
var action = $q.defer();
backend.post('/events', options).then(function(data) {
pageUtils.getPageInformation(data, pageInformation, options.page);
action.resolve(data);
}, function(response) {
action.reject(response);
});
return action.promise;
};

this.retrieveRecent = function() {
return backend.retrieve('/notifications/recent');
};
Expand Down
35 changes: 26 additions & 9 deletions mod-picker/app/assets/javascripts/BackendAPI/tagService.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
app.service('tagService', function(backend, $q) {
this.retrieveTags = function() {
var tags = $q.defer();
var postData = {
filters: {}
};
backend.post('/tags', postData).then(function(data) {
tags.resolve(data);
app.service('tagService', function(backend, $q, pageUtils) {
this.retrieveAllTags = function() {
var params = { game: window._current_game_id };
return backend.retrieve('/all_tags', params);
};

this.retrieveTags = function(options, pageInformation) {
var action = $q.defer();
backend.post('/tags', options).then(function(data) {
// resolve page information and data
pageUtils.getPageInformation(data, pageInformation, options.page);
action.resolve(data);
}, function(response) {
action.reject(response);
});
return tags.promise;
return action.promise;
};

this.hideTag = function(tagId, hidden) {
return backend.post('/tags/' + tagId + '/hide', {hidden: hidden});
};

this.updateTag = function(tag) {
var params = {
tag: { text: tag.text }
};
return backend.update('/tags/' + tag.id, params);
};

this.updateModTags = function(mod, tags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ app.directive('notification', function() {

app.controller('notificationController', function($scope, $sce, $interpolate, notificationsFactory) {
angular.inherit($scope, 'notification');
$scope.event = $scope.notification.event;
if ($scope.notification.hasOwnProperty('event')) {
$scope.event = $scope.notification.event;
} else {
$scope.event = $scope.notification;
}
$scope.content = $scope.event.content;

// get template based on event type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ app.directive('readMore', function() {
});

app.controller('readMoreController', function($scope) {
$scope.reducedText = $scope.text.reduceText($scope.numWords);

// TODO: add methods to contribution models to trim beginning/end whitespace
// for text_body; current regex is to stop read more from showing up unnecessarily.
$scope.text = $scope.text.trim();
$scope.expandable = $scope.text.wordCount() > $scope.numWords * 1.25 &&
$scope.reducedText.length < $scope.text.length;

$scope.expanded = false;
$scope.toggleExpansion = function() {
$scope.expanded = !$scope.expanded;
};

$scope.getReducedText = function() {
$scope.reducedText = $scope.text.reduceText($scope.numWords);
// TODO: add methods to contribution models to trim beginning/end whitespace
// for text_body; current regex is to stop read more from showing up unnecessarily.
$scope.text = $scope.text.trim();
$scope.expandable = $scope.text.wordCount() > $scope.numWords * 1.25 &&
$scope.reducedText.length < $scope.text.length;
};

$scope.$watch('text', $scope.getReducedText);
$scope.getReducedText();
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ app.controller('modAnalysisManagerController', function($scope, $rootScope, plug
document.getElementById('analysis-input').click();
};

$scope.clearAnalysis = function() {
var modOptions = $scope.mod.analysis ? $scope.mod.analysis.mod_options : $scope.mod.mod_options;
modOptions.forEach(function(modOption) {
if (modOption.id) {
modOption._destroy = true;
} else {
$scope.removeOption(modOption);
}
});
};

$scope.removeOption = function(option) {
var modOptions = $scope.mod.analysis.mod_options;
var index = modOptions.indexOf(option);
Expand Down Expand Up @@ -100,11 +111,11 @@ app.controller('modAnalysisManagerController', function($scope, $rootScope, plug
};

$scope.optionNamesMatch = function(option, oldOption) {
return option.name === oldOption.name;
return option.name === oldOption.name && !oldOption._destroy;
};

$scope.optionSizesMatch = function(option, oldOption) {
return option.size == oldOption.size;
return option.size == oldOption.size && !oldOption._destroy;
};

$scope.findOldOption = function(oldOptions, option) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
app.directive('editTagModal', function() {
return {
restrict: 'E',
templateUrl: '/resources/directives/shared/editTagModal.html',
controller: 'editTagModalController',
scope: false
}
});

app.controller('editTagModalController', function($scope, tagService, formUtils, eventHandlerFactory) {
// inherited functions
$scope.unfocusTagModal = formUtils.unfocusModal($scope.toggleTagModal);

// shared function setup
eventHandlerFactory.buildModalMessageHandlers($scope);

$scope.saveTag = function() {
tagService.updateTag($scope.activeTag).then(function() {
$scope.$emit('modalSuccessMessage', 'Updated tag "' + $scope.activeTag.text + '"successfully');
$scope.$applyAsync(function() {
$scope.originalTag.text = $scope.activeTag.text;
});
}, function(response) {
var params = {
text: 'Error updating tag: '+$scope.activeTag.text,
response: response
};
$scope.$emit('modalErrorMessage', params);
});
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
app.directive('modOptionTree', function() {
return {
restrict: 'E',
templateUrl: '/resources/directives/shared/modOptionTree.html',
scope: {
modOptions: '='
},
controller: 'modOptionTreeController'
}
});

app.controller('modOptionTreeController', function($scope) {
$scope.toggleModOption = function(option) {
// recurse into children
option.children && option.children.forEach(function(child) {
if (child.active && !option.active) {
child.active = false;
}
});
// emit message
$scope.$emit('toggleModOption', option);
};

$scope.toggleExpansion = function(option) {
option.expanded = !option.expanded;
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ app.directive('tagSelector', function() {
}
});

app.controller('tagSelectorController', function($scope, tagService) {
app.controller('tagSelectorController', function($scope, $element, $timeout, tagService) {
$scope.rawNewTags = [];
$scope.removedTags = [];
var addTagButton = $element[0].firstChild.lastElementChild;

tagService.retrieveTags().then(function(data) {
tagService.retrieveAllTags().then(function(data) {
$scope.tags = data;
});

Expand All @@ -36,6 +37,12 @@ app.controller('tagSelectorController', function($scope, tagService) {
}
};

$scope.focusAddTag = function() {
$timeout(function() {
addTagButton.focus();
}, 50);
};

$scope.removeTag = function($index) {
$scope.rawNewTags.splice($index, 1);
$scope.storeTags();
Expand Down
34 changes: 34 additions & 0 deletions mod-picker/app/assets/javascripts/Factories/actionsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,38 @@ app.service('actionsFactory', function() {
}]
}];
};

/* tag actions */
this.tagIndexActions = function() {
return [{
caption: "Edit",
title: "Edit this tag's text",
hidden: function($scope, item) {
return item.hidden || !$scope.permissions.canModerate;
},
execute: function($scope, item) {
$scope.$emit('editTag', item);
}
}, {
caption: "Recover",
title: "This tag is hidden. Click to recover it.",
class: 'green-box',
hidden: function($scope, item) {
return !item.hidden;
},
execute: function($scope, item) {
$scope.$emit('recoverTag', item);
}
}, {
caption: "Hide",
title: "This tag is publicly visible. Click to hide it.",
class: 'yellow-box',
hidden: function($scope, item) {
return item.hidden;
},
execute: function($scope, item) {
$scope.$emit('hideTag', item);
}
}]
};
});
1 change: 1 addition & 0 deletions mod-picker/app/assets/javascripts/Factories/baseFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ app.service('baseFactory', function() {
index: 0,
group_id: 0,
name: "",
url: "",
description: "",
is_utility: false
}
Expand Down
Loading

0 comments on commit 115aa3f

Please sign in to comment.