Merge "Allow adding cpid to null product version"
This commit is contained in:
commit
62eee7589b
@ -7,6 +7,7 @@
|
|||||||
<strong>Name:</strong> {{ctrl.product.name}}<br />
|
<strong>Name:</strong> {{ctrl.product.name}}<br />
|
||||||
<strong>Product ID:</strong> {{ctrl.id}}<br />
|
<strong>Product ID:</strong> {{ctrl.id}}<br />
|
||||||
<strong>Description:</strong> {{ctrl.product.description}}<br />
|
<strong>Description:</strong> {{ctrl.product.description}}<br />
|
||||||
|
<span ng-if="ctrl.nullVersion.cpid"><strong>CPID:</strong> {{ctrl.nullVersion.cpid}}<br /></span>
|
||||||
<strong>Publicity:</strong> {{ctrl.product.public ? 'Public' : 'Private'}}<br />
|
<strong>Publicity:</strong> {{ctrl.product.public ? 'Public' : 'Private'}}<br />
|
||||||
<strong>Vendor Name:</strong> <a ui-sref="vendor({vendorID: ctrl.vendor.id})">{{ctrl.vendor.name}}</a><br />
|
<strong>Vendor Name:</strong> <a ui-sref="vendor({vendorID: ctrl.vendor.id})">{{ctrl.vendor.name}}</a><br />
|
||||||
<div ng-if="ctrl.productProperties">
|
<div ng-if="ctrl.productProperties">
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<strong>Name:</strong> {{ctrl.product.name}}<br />
|
<strong>Name:</strong> {{ctrl.product.name}}<br />
|
||||||
<strong>Product ID:</strong> {{ctrl.id}}<br />
|
<strong>Product ID:</strong> {{ctrl.id}}<br />
|
||||||
<strong>Description:</strong> {{ctrl.product.description}}<br />
|
<strong>Description:</strong> {{ctrl.product.description}}<br />
|
||||||
|
<span ng-if="ctrl.nullVersion.cpid"><strong>CPID:</strong> {{ctrl.nullVersion.cpid}}<br /></span>
|
||||||
<strong>Publicity:</strong> {{ctrl.product.public ? 'Public' : 'Private'}}<br />
|
<strong>Publicity:</strong> {{ctrl.product.public ? 'Public' : 'Private'}}<br />
|
||||||
<strong>Vendor Name:</strong> <a ui-sref="vendor({vendorID: ctrl.vendor.id})">{{ctrl.vendor.name}}</a><br />
|
<strong>Vendor Name:</strong> <a ui-sref="vendor({vendorID: ctrl.vendor.id})">{{ctrl.vendor.name}}</a><br />
|
||||||
<div ng-if="ctrl.productProperties">
|
<div ng-if="ctrl.productProperties">
|
||||||
|
@ -42,6 +42,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div><small><a ng-click="modal.addField()"><span class="glyphicon glyphicon-plus"></span> Add new property</a></small></div>
|
<div><small><a ng-click="modal.addField()"><span class="glyphicon glyphicon-plus"></span> Add new property</a></small></div>
|
||||||
|
<br />
|
||||||
|
<div ng-if="modal.productVersion.id">
|
||||||
|
<label for="name">Product CPID</label>
|
||||||
|
<small>
|
||||||
|
<span class="text-muted glyphicon glyphicon-info-sign"
|
||||||
|
title="You can optionally associate a cloud provider ID to this product. This is used to automatically associate uploaded test results to the product.">
|
||||||
|
</span>
|
||||||
|
</small>
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
id="cpid"
|
||||||
|
ng-model="modal.productVersion.cpid">
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="modal.showError" class="alert alert-danger" role="alert">
|
<div ng-show="modal.showError" class="alert alert-danger" role="alert">
|
||||||
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
||||||
|
@ -112,6 +112,14 @@
|
|||||||
ctrl.productVersionsRequest = $http.get(content_url).success(
|
ctrl.productVersionsRequest = $http.get(content_url).success(
|
||||||
function(data) {
|
function(data) {
|
||||||
ctrl.productVersions = data;
|
ctrl.productVersions = data;
|
||||||
|
|
||||||
|
// Determine the null version.
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
if (data[i].version === null) {
|
||||||
|
ctrl.nullVersion = data[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
).error(function(error) {
|
).error(function(error) {
|
||||||
ctrl.showError = true;
|
ctrl.showError = true;
|
||||||
@ -310,6 +318,9 @@
|
|||||||
resolve: {
|
resolve: {
|
||||||
product: function () {
|
product: function () {
|
||||||
return ctrl.product;
|
return ctrl.product;
|
||||||
|
},
|
||||||
|
version: function () {
|
||||||
|
return ctrl.nullVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -385,7 +396,8 @@
|
|||||||
.controller('ProductEditModalController', ProductEditModalController);
|
.controller('ProductEditModalController', ProductEditModalController);
|
||||||
|
|
||||||
ProductEditModalController.$inject = [
|
ProductEditModalController.$inject = [
|
||||||
'$uibModalInstance', '$http', '$state', 'product', 'refstackApiUrl'
|
'$uibModalInstance', '$http', '$state', 'product',
|
||||||
|
'version', 'refstackApiUrl'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -393,7 +405,7 @@
|
|||||||
* This controls the modal that allows editing a product.
|
* This controls the modal that allows editing a product.
|
||||||
*/
|
*/
|
||||||
function ProductEditModalController($uibModalInstance, $http,
|
function ProductEditModalController($uibModalInstance, $http,
|
||||||
$state, product, refstackApiUrl) {
|
$state, product, version, refstackApiUrl) {
|
||||||
|
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
@ -405,6 +417,8 @@
|
|||||||
ctrl.product = angular.copy(product);
|
ctrl.product = angular.copy(product);
|
||||||
ctrl.productName = product.name;
|
ctrl.productName = product.name;
|
||||||
ctrl.productProperties = [];
|
ctrl.productProperties = [];
|
||||||
|
ctrl.productVersion = angular.copy(version);
|
||||||
|
ctrl.originalCpid = version ? version.cpid : null;
|
||||||
|
|
||||||
parseProductProperties();
|
parseProductProperties();
|
||||||
|
|
||||||
@ -436,14 +450,34 @@
|
|||||||
if (ctrl.productName != ctrl.product.name) {
|
if (ctrl.productName != ctrl.product.name) {
|
||||||
content.name = ctrl.product.name;
|
content.name = ctrl.product.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request for product detail updating.
|
||||||
|
$http.put(url, content).success(function() {
|
||||||
|
|
||||||
|
// Request for product version CPID update if it has changed.
|
||||||
|
if (ctrl.productVersion &&
|
||||||
|
ctrl.originalCpid !== ctrl.productVersion.cpid) {
|
||||||
|
|
||||||
|
url = url + '/versions/' + ctrl.productVersion.id;
|
||||||
|
content = {'cpid': ctrl.productVersion.cpid};
|
||||||
$http.put(url, content).success(function() {
|
$http.put(url, content).success(function() {
|
||||||
ctrl.showSuccess = true;
|
ctrl.showSuccess = true;
|
||||||
|
ctrl.originalCpid = ctrl.productVersion.cpid;
|
||||||
$state.reload();
|
$state.reload();
|
||||||
}).error(function(error) {
|
}).error(function(error) {
|
||||||
ctrl.showError = true;
|
ctrl.showError = true;
|
||||||
ctrl.error = error.detail;
|
ctrl.error = error.detail;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ctrl.showSuccess = true;
|
||||||
|
$state.reload();
|
||||||
|
}
|
||||||
|
}).error(function(error) {
|
||||||
|
ctrl.showError = true;
|
||||||
|
ctrl.error = error.detail;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a property from the productProperties array at the given
|
* Remove a property from the productProperties array at the given
|
||||||
|
@ -1479,6 +1479,8 @@ describe('Refstack controllers', function () {
|
|||||||
var ctrl, modalInstance, state;
|
var ctrl, modalInstance, state;
|
||||||
var fakeProduct = {'name': 'Foo', 'description': 'Bar', 'id': '1234',
|
var fakeProduct = {'name': 'Foo', 'description': 'Bar', 'id': '1234',
|
||||||
'properties': {'key1': 'value1'}};
|
'properties': {'key1': 'value1'}};
|
||||||
|
var fakeVersion = {'version': null, 'product_id': '1234',
|
||||||
|
'cpid': null, 'id': 'asdf'};
|
||||||
|
|
||||||
beforeEach(inject(function ($controller) {
|
beforeEach(inject(function ($controller) {
|
||||||
modalInstance = {
|
modalInstance = {
|
||||||
@ -1489,7 +1491,8 @@ describe('Refstack controllers', function () {
|
|||||||
};
|
};
|
||||||
ctrl = $controller('ProductEditModalController',
|
ctrl = $controller('ProductEditModalController',
|
||||||
{$uibModalInstance: modalInstance, $state: state,
|
{$uibModalInstance: modalInstance, $state: state,
|
||||||
product: fakeProduct}
|
product: fakeProduct,
|
||||||
|
version: fakeVersion}
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -1510,9 +1513,14 @@ describe('Refstack controllers', function () {
|
|||||||
'name': 'Foo1', 'description': 'Bar',
|
'name': 'Foo1', 'description': 'Bar',
|
||||||
'properties': {'key1': 'value1'}
|
'properties': {'key1': 'value1'}
|
||||||
};
|
};
|
||||||
|
var verContent = {'cpid': 'abc'};
|
||||||
$httpBackend.expectPUT(
|
$httpBackend.expectPUT(
|
||||||
fakeApiUrl + '/products/1234', expectedContent)
|
fakeApiUrl + '/products/1234', expectedContent)
|
||||||
.respond(200, '');
|
.respond(200, '');
|
||||||
|
$httpBackend.expectPUT(
|
||||||
|
fakeApiUrl + '/products/1234/versions/asdf', verContent)
|
||||||
|
.respond(200, '');
|
||||||
|
ctrl.productVersion.cpid = 'abc';
|
||||||
ctrl.product.name = 'Foo1';
|
ctrl.product.name = 'Foo1';
|
||||||
ctrl.saveChanges();
|
ctrl.saveChanges();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user