Permalink
Browse files

Merge branch 'master' into 354-add-possibility-to-rebuild-projects-pe…

…riodically
  • Loading branch information...
2 parents 4250e31 + 34a6346 commit e1260ea40b8a688cade19d6a644d932bf3bbb141 @avokhmin avokhmin committed Feb 19, 2014
View
30 app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb
@@ -2,14 +2,15 @@ RosaABF.controller('BuildListController', ['$scope', '$http', '$timeout', 'Sound
$scope.advisoriable_types = <%=BuildList::RELEASE_UPDATE_TYPES%>;
- $scope.id = $('#build_list_id').val();
- $scope.build_list = null;
- $scope.subject = {}; // See: shared/build_results
- $scope.attach_advisory = 'no';
+ $scope.id = $('#build_list_id').val();
+ $scope.build_list = null;
+ $scope.subject = {}; // See: shared/build_results
+ $scope.attach_advisory = 'no';
// Statuses: advisory_not_found, server_error, continue_input
- $scope.search_status = 'continue_input';
- $scope.term = '';
- $scope.advisory = null;
+ $scope.search_status = 'continue_input';
+ $scope.term = '';
+ $scope.advisory = null;
+ $scope.update_type_errors = null;
$scope.getBuildList = function() {
$http.get(Routes.build_list_path($scope.id, {format: 'json'})).success(function(results) {
@@ -60,13 +61,28 @@ RosaABF.controller('BuildListController', ['$scope', '$http', '$timeout', 'Sound
} else {
$scope.attach_advisory = 'no';
}
+ $scope.updateUpdateType();
}
$scope.attachAdvisoryChanged = function() {
if (!_.contains($scope.advisoriable_types, $scope.build_list.update_type)) {
$scope.build_list.update_type = $scope.advisoriable_types[0];
+ $scope.updateUpdateType();
}
$('#build_list_update_type .nonadvisoriable').attr('disabled', ($scope.attach_advisory != 'no'));
}
+ $scope.updateUpdateType = function() {
+ $http.put(
+ Routes.update_type_build_list_path($scope.id),
+ {update_type: $scope.build_list.update_type, format: 'json'}
+ ).success(function(results) {
+ $scope.update_type_errors = null;
+ $timeout(function() {
+ $('#build_list_update_type').effect('highlight', {}, 1000);
+ }, 100);
+ }).error(function(data, status, headers, config) {
+ $scope.update_type_errors = data.message;
+ });
+ }
}]);
View
14 app/controllers/projects/build_lists_controller.rb
@@ -166,6 +166,20 @@ def list
render partial: 'build_lists_ajax', layout: false
end
+ def update_type
+ respond_to do |format|
+ format.html { render nothing: true }
+ format.json do
+ @build_list.update_type = params[:update_type]
+ if @build_list.save
+ render json: 'success', status: :ok
+ else
+ render json: { message: @build_list.errors.full_messages.join('. ') },
+ status: :unprocessable_entity
+ end
+ end
+ end
+ end
protected
View
5 app/views/projects/build_lists/show.html.haml
@@ -51,6 +51,11 @@
@build_list.update_type), {}, 'ng-model' => 'build_list.update_type',
'ng-change' => 'updateTypeChanged()', 'ng-show' => 'build_list.can_publish'
%div{'ng-hide' => 'build_list.can_publish'}= @build_list.update_type
+ .ng-hide{ 'ng-show' => 'update_type_errors' }
+ .flash_notify
+ .alert{ 'ng-class' => "{ 'alert-error': update_type_errors }" }
+ {{ update_type_errors }}
+ .both
.both
.leftlist= t("activerecord.attributes.build_list.auto_publish")
.rightlist= t("layout.#{@build_list.auto_publish}_")
View
1 config/routes.rb
@@ -282,6 +282,7 @@
put :publish
put :reject_publish
put :publish_into_testing
+ put :update_type
end
end

0 comments on commit e1260ea

Please sign in to comment.