From e9c023f273cf585132d951363af1be76f7497372 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 7 Feb 2013 15:11:57 +0400 Subject: [PATCH] #898: add "publish_i686_into_x86_64" field into Project, update UI --- .../backbone/views/project_modify_view.js | 13 +++++++--- app/models/project.rb | 2 +- .../api/v1/build_lists/show.json.jbuilder | 2 +- app/views/projects/projects/_form.html.haml | 24 ++++++++++++------- config/locales/models/project.en.yml | 1 + config/locales/models/project.ru.yml | 1 + ...8_add_publishi686_into_x8664_to_project.rb | 5 ++++ db/schema.rb | 17 ++++++------- 8 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 db/migrate/20130207101148_add_publishi686_into_x8664_to_project.rb diff --git a/app/assets/javascripts/backbone/views/project_modify_view.js b/app/assets/javascripts/backbone/views/project_modify_view.js index 348b9a50e..2c11de294 100644 --- a/app/assets/javascripts/backbone/views/project_modify_view.js +++ b/app/assets/javascripts/backbone/views/project_modify_view.js @@ -2,9 +2,11 @@ Rosa.Views.ProjectModifyView = Backbone.View.extend({ initialize: function() { _.bindAll(this, 'checkboxClick'); - this.$checkbox_wrapper = $('#niceCheckbox1'); - this._$checkbox = this.$checkbox_wrapper.children('#project_is_package').first(); - this.$maintainer_form = $('#maintainer_form'); + this.$checkbox_wrapper = $('#niceCheckbox1'); + this._$checkbox = this.$checkbox_wrapper.children('#project_is_package').first(); + this.$maintainer_form = $('#maintainer_form'); + this.$publish_form = $('#publish_form'); + this._$publish_checkbox = this.$publish_form.find('#project_publish_i686_into_x86_64').first(); this.$checkbox_wrapper.on('click', this.checkboxClick); }, @@ -12,8 +14,13 @@ Rosa.Views.ProjectModifyView = Backbone.View.extend({ checkboxClick: function() { if (this._$checkbox.is(':checked')) { this.$maintainer_form.slideDown(); + this.$publish_form.slideDown(); } else { this.$maintainer_form.slideUp(); + this.$publish_form.slideUp(); + if (this._$publish_checkbox.is(':checked')) { + changeCheck(this.$publish_form.find('.niceCheck-main')); + } } }, diff --git a/app/models/project.rb b/app/models/project.rb index f1f395ff4..264e77fe4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -32,7 +32,7 @@ class Project < ActiveRecord::Base validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS } validate :check_default_branch - attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki, :maintainer_id + attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki, :maintainer_id, :publish_i686_into_x86_64 attr_readonly :name, :owner_id, :owner_type scope :recent, order("name ASC") diff --git a/app/views/api/v1/build_lists/show.json.jbuilder b/app/views/api/v1/build_lists/show.json.jbuilder index 720d9a48e..595f75ab1 100644 --- a/app/views/api/v1/build_lists/show.json.jbuilder +++ b/app/views/api/v1/build_lists/show.json.jbuilder @@ -2,7 +2,7 @@ json.build_list do |json| json.(@build_list, :id, :name, :container_status, :status, :duration) json.(@build_list, :is_circle, :update_type, :priority, :new_core) json.(@build_list, :advisory, :mass_build, :use_save_to_repository) - json.(@build_list, :auto_publish, :package_version, :commit_hash, :last_published_commit_hash) + json.(@build_list, :auto_publish, :package_version, :commit_hash, :last_published_commit_hash, :publish_i686_into_x86_64) json.build_log_url log_build_list_path(@build_list) if @build_list.container_published? diff --git a/app/views/projects/projects/_form.html.haml b/app/views/projects/projects/_form.html.haml index 6bf9cb82a..830855d80 100644 --- a/app/views/projects/projects/_form.html.haml +++ b/app/views/projects/projects/_form.html.haml @@ -1,13 +1,13 @@ - act = controller.action_name.to_sym - if [:new, :create].include? act - .leftlist= f.label :name, t("activerecord.attributes.project.name"), :class => :label + .leftlist= f.label :name .rightlist= f.text_field :name, :class => 'text_field', :disabled => f.object.try(:persisted?) .both -.leftlist= f.label :description, t("activerecord.attributes.project.description"), :class => :label +.leftlist= f.label :description .rightlist= f.text_area :description, :class => 'text_field', :cols => 80 .both - if [:new, :create].include? act - .leftlist= f.label :owner_id, t("activerecord.attributes.project.owner"), :class => :label + .leftlist= f.label :owner .rightlist = label_tag t("activerecord.attributes.project.who_owns.me") - if Group.can_own_project(current_user).count > 0 @@ -20,7 +20,7 @@ = hidden_field_tag :who_owns, :me .both -.leftlist= f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label +.leftlist= f.label :visibility .rightlist =# f.select :visibility, Project::VISIBILITIES - Project::VISIBILITIES.each do |visibility| @@ -35,12 +35,18 @@ \  .rightlist .check - %span#niceCheckbox1.niceCheck-main= f.check_box :is_package#, :class => 'niceCheckbox1' - .forcheck= t("activerecord.attributes.project.is_package") + %span#niceCheckbox1.niceCheck-main= f.check_box :is_package + .forcheck= f.label :is_package .both + #publish_form{:class => @project.publish_i686_into_x86_64 ? '' : 'hidden'} + .check + %span.niceCheck-main= f.check_box :publish_i686_into_x86_64 + .forcheck= f.label :publish_i686_into_x86_64 + .both + .both - if [:edit, :update].include? act - .leftlist= t("activerecord.attributes.project.default_branch") + .leftlist= f.label :default_branch .rightlist = f.select :default_branch, options_from_collection_for_select( @project.repo.branches, @@ -50,7 +56,7 @@ #maintainer_form{:class => @project.is_package ? '' : 'hidden'} = f.hidden_field :maintainer_id, :value => @project.maintainer_id .leftlist - = t("activerecord.attributes.project.maintainer") + = f.label :maintainer .rightlist -# TODO: Maybe use something like Chosen with filter and prepopulated -# list of potential maintainers? @@ -59,7 +65,7 @@ :id_element => '#project_maintainer_id', :placeholder => @project.maintainer.fullname - if [:new, :create].include? act - .leftlist= f.label :srpm, t("activerecord.attributes.project.srpm"), :class => :label + .leftlist= f.label :srpm .rightlist= f.file_field :srpm, :class => 'file_field' .both .leftlist diff --git a/config/locales/models/project.en.yml b/config/locales/models/project.en.yml index 3a617ba6b..92b46cd12 100644 --- a/config/locales/models/project.en.yml +++ b/config/locales/models/project.en.yml @@ -94,6 +94,7 @@ en: group: Group default_branch: Default branch is_package: Project is a package + publish_i686_into_x86_64: Publish i686 packages into x86_64 repository (only for rhel) maintainer: Maintainer of project maintainer_id: Maintainer of project errors: diff --git a/config/locales/models/project.ru.yml b/config/locales/models/project.ru.yml index 916052de3..60b13d39f 100644 --- a/config/locales/models/project.ru.yml +++ b/config/locales/models/project.ru.yml @@ -94,6 +94,7 @@ ru: group: Группа default_branch: Ветка по умолчанию is_package: Проект является пакетом + publish_i686_into_x86_64: Публиковать i686 пакеты в x86_64 репозиторий (только для rhel) maintainer_id: Майнтейнер проекта maintainer: Майнтейнер проекта errors: diff --git a/db/migrate/20130207101148_add_publishi686_into_x8664_to_project.rb b/db/migrate/20130207101148_add_publishi686_into_x8664_to_project.rb new file mode 100644 index 000000000..3f27f757f --- /dev/null +++ b/db/migrate/20130207101148_add_publishi686_into_x8664_to_project.rb @@ -0,0 +1,5 @@ +class AddPublishi686IntoX8664ToProject < ActiveRecord::Migration + def change + add_column :projects, :publish_i686_into_x86_64, :boolean, :default => false + end +end diff --git a/db/schema.rb b/db/schema.rb index d8d8791d0..0c49cf208 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130201094007) do +ActiveRecord::Schema.define(:version => 20130207101148) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -354,20 +354,21 @@ ActiveRecord::Schema.define(:version => 20130201094007) do t.datetime "updated_at" t.integer "owner_id" t.string "owner_type" - t.string "visibility", :default => "open" + t.string "visibility", :default => "open" t.text "description" t.string "ancestry" - t.boolean "has_issues", :default => true + t.boolean "has_issues", :default => true t.string "srpm_file_name" t.integer "srpm_file_size" t.datetime "srpm_updated_at" t.string "srpm_content_type" - t.boolean "has_wiki", :default => false - t.string "default_branch", :default => "master" - t.boolean "is_package", :default => true, :null => false - t.integer "average_build_time", :default => 0, :null => false - t.integer "build_count", :default => 0, :null => false + t.boolean "has_wiki", :default => false + t.string "default_branch", :default => "master" + t.boolean "is_package", :default => true, :null => false + t.integer "average_build_time", :default => 0, :null => false + t.integer "build_count", :default => 0, :null => false t.integer "maintainer_id" + t.boolean "publish_i686_into_x86_64", :default => false end add_index "projects", ["owner_id", "name", "owner_type"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false