mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
Comparison bug when deleting builds
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
angular.module('app').controller('ComparisonController', ['lodash', '$rootScope', '$filter', '$scope', '$state', '$stateParams', 'Utils', 'ShipFacets', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function (_, $rootScope, $filter, $scope, $state, $stateParams, Utils, ShipFacets, Ships, Ship, Persist, Serializer) {
|
||||
$rootScope.title = 'Coriolis - Compare';
|
||||
$scope.predicate = 'ship.name'; // Sort by ship name as default
|
||||
$scope.desc = true;
|
||||
$scope.predicate = 'name'; // Sort by ship name as default
|
||||
$scope.desc = false;
|
||||
$scope.facetSortOpts = { containment: '#facet-container', orderChanged: function () { $scope.saved = false; } };
|
||||
$scope.builds = [];
|
||||
$scope.unusedBuilds = [];
|
||||
@@ -99,7 +99,7 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
|
||||
}
|
||||
});
|
||||
Persist.saveComparison($scope.name, $scope.builds, selectedFacets);
|
||||
$state.go('compare', {name: $scope.name}, {location:'replace', reload:false});
|
||||
$state.go('compare', {name: $scope.name}, {location:'replace', notify:false});
|
||||
$scope.saved = true;
|
||||
};
|
||||
|
||||
@@ -111,22 +111,41 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
|
||||
$state.go('compare', {name: null}, {location:'replace', reload:true});
|
||||
};
|
||||
|
||||
/**
|
||||
* Set saved to false when the name of the comparison is changed.
|
||||
*/
|
||||
$scope.nameChange = function() {
|
||||
$scope.saved = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide/Show the select builds menu
|
||||
* @param {boolean} s Show true/false
|
||||
* @param {Event} e Event Object
|
||||
*/
|
||||
$scope.selectBuilds = function(s, e) {
|
||||
e.stopPropagation();
|
||||
$scope.showBuilds = s;
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the permalink modal
|
||||
* @param {Event} e Event object
|
||||
*/
|
||||
$scope.permalink = function(e) {
|
||||
e.stopPropagation();
|
||||
$state.go('modal.link', {url: genPermalink()});
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate the forum embed code for the comparison
|
||||
* and show the export modal.
|
||||
*
|
||||
* @param {Event} e Event object
|
||||
*/
|
||||
$scope.embed = function(e) {
|
||||
e.stopPropagation();
|
||||
// Make a request to goo.gl to shorten the URL, returns a promise
|
||||
var promise = Utils.shortenUrl( genPermalink()).then(
|
||||
function (shortUrl) {
|
||||
return Utils.comparisonBBCode(facets, $scope.builds, shortUrl);
|
||||
@@ -138,6 +157,10 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
|
||||
$state.go('modal.export', {promise: promise, title:'Forum BBCode'});
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates the long permalink URL
|
||||
* @return {string} The long permalink URL
|
||||
*/
|
||||
function genPermalink() {
|
||||
var selectedFacets = [];
|
||||
facets.forEach(function(f) {
|
||||
@@ -202,11 +225,10 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
|
||||
throw { type: 'bad-comparison', message: e.message, details: e };
|
||||
}
|
||||
}
|
||||
|
||||
// Replace fmt with actual format function as defined in rootScope and retain original index
|
||||
facets.forEach(function(f,i) { f.fmt = $rootScope[f.fmt]; f.index = i; });
|
||||
// Remove default facets, mark as active, and add them back in selected order
|
||||
_.pullAt(facets, defaultFacets).forEach(function (f) { f.active = true; facets.unshift(f); });
|
||||
|
||||
$scope.builds = $filter('orderBy')($scope.builds, $scope.predicate, $scope.desc);
|
||||
|
||||
}]);
|
||||
@@ -12,18 +12,15 @@ angular.module('app')
|
||||
$scope.msgPost = 'Not Found';
|
||||
break;
|
||||
case 'no-ship':
|
||||
//$rootScope.bodyClass = 'docking-bay';
|
||||
$scope.msgPre = 'Ship';
|
||||
$scope.msgHighlight = $p.message;
|
||||
$scope.msgPost = 'does not exist';
|
||||
break;
|
||||
case 'build-fail':
|
||||
//$rootScope.bodyClass = 'ship-explode'; // TODO: create background imag for this
|
||||
$scope.msgPre = 'Build Failure!';
|
||||
$scope.details = $p.details;
|
||||
break;
|
||||
default:
|
||||
//$rootScope.bodyClass = 'thargoid'; // TODO: create background imag for this
|
||||
$scope.msgPre = "Uh, Jameson, we have a problem..";
|
||||
$scope.errorMessage = $p.message;
|
||||
$scope.details = $p.details;
|
||||
|
||||
@@ -130,15 +130,26 @@ angular.module('app').controller('OutfitController', ['$rootScope','$scope', '$s
|
||||
$state.go('outfit', {shipId: ship.id, code: null, bn: null}, {location:'replace', reload:true});
|
||||
};
|
||||
|
||||
/**
|
||||
* On build name change, retrieve the existing saved code if there is one
|
||||
*/
|
||||
$scope.bnChange = function(){
|
||||
$scope.savedCode = Persist.getBuild(ship.id, $scope.buildName);
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle cost of the selected component
|
||||
* @param {object} item The component being toggled
|
||||
*/
|
||||
$scope.toggleCost = function(item) {
|
||||
item.incCost = !item.incCost;
|
||||
ship.updateTotals();
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the power on/off for the selected component
|
||||
* @param {object} item The component being toggled
|
||||
*/
|
||||
$scope.togglePwr = function(item) {
|
||||
item.enabled = !item.enabled;
|
||||
ship.updateTotals();
|
||||
|
||||
@@ -28,11 +28,15 @@ angular.module('app').directive('shipyardHeader', ['lodash','$window','$rootScop
|
||||
scope.openedMenu = null;
|
||||
});
|
||||
|
||||
// Listen to close event to close opened menus or modals
|
||||
$rootScope.$on('close', function () {
|
||||
scope.openedMenu = null;
|
||||
$rootScope.showAbout = false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Save selected insurance option in localstorage
|
||||
*/
|
||||
scope.updateInsurance = function(){
|
||||
$window.localStorage.setItem('insurance', $rootScope.insurance.current.name);
|
||||
};
|
||||
|
||||
@@ -72,7 +72,16 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
|
||||
}
|
||||
// Persist updated build collection to localStorage
|
||||
localStorage.setItem(LS_KEY_BUILDS, angular.toJson(this.builds));
|
||||
// TODO: Check if build exists in comparisons
|
||||
// Check if the build was used in existing comparisons
|
||||
var comps = this.comparisons;
|
||||
for (var c in comps) {
|
||||
for (var i = 0; i < comps[c].builds.length; i++) { // For all builds in the current comparison
|
||||
if(comps[c].builds[i].shipId == shipId && comps[c].builds[i].buildName == name) {
|
||||
comps[c].builds.splice(i,1);
|
||||
break; // A build is unique ber comparison
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "coriolis_shipyard",
|
||||
"version": "0.7.5",
|
||||
"version": "0.7.7",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/cmmcleod/coriolis"
|
||||
|
||||
Reference in New Issue
Block a user