-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add repository_form template and its js controller
- Loading branch information
1 parent
1613524
commit 6e1f411
Showing
10 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
app/assets/javascripts/controllers/ansible_repository/repository_form_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
ManageIQ.angular.app.controller('repositoryFormController', ['$http', '$scope', 'repositoryId', 'miqService', function($http, $scope, repositoryId, miqService) { | ||
var vm = this; | ||
|
||
var init = function() { | ||
vm.repositoryModel = { | ||
name: '', | ||
description: '', | ||
scm_type: '', | ||
url: '', | ||
scm_credentials: '', | ||
branch: '', | ||
clean: false, | ||
deleteOnUpdate: false, | ||
updateOnLaunch: false, | ||
}; | ||
|
||
vm.afterGet = false; | ||
|
||
vm.model = 'repositoryModel'; | ||
vm.newRecord = false; | ||
|
||
ManageIQ.angular.scope = vm; | ||
|
||
miqService.sparkleOn(); | ||
// TODO change to API | ||
if (repositoryId != 'new') { | ||
$http.get('/ansible_repository/dummy_data') | ||
.then(getRepositoryFormData) | ||
.catch(miqService.handleFailure); | ||
} | ||
else { | ||
vm.afterGet = true; | ||
vm.modelCopy = angular.copy( vm.repositoryModel ); | ||
} | ||
}; | ||
|
||
$scope.cancelClicked = function() { | ||
// TODO go back | ||
}; | ||
|
||
$scope.resetClicked = function() { | ||
debugger; | ||
vm.repositoryModel = angular.copy( vm.modelCopy ); | ||
$scope.angularForm.$setPristine(true); | ||
miqService.miqFlash("warn", __("All changes have been reset")); | ||
}; | ||
|
||
$scope.saveClicked = function() { | ||
$scope.angularForm.$setPristine(true); | ||
}; | ||
|
||
$scope.addClicked = function() { | ||
// URL is different from save, maybe? | ||
$scope.saveClicked(); | ||
}; | ||
|
||
function getRepositoryFormData(response) { | ||
var data = response.data; | ||
|
||
Object.assign(vm.repositoryModel, data); | ||
|
||
$scope.afterGet = true; | ||
vm.modelCopy = angular.copy(vm.repositoryModel); | ||
|
||
miqService.sparkleOff(); | ||
} | ||
|
||
init(); | ||
}]); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ApplicationHelper::Button::AnsibleRepository < ApplicationHelper::Button::Basic | ||
def disabled? | ||
@record.nil? | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
app/helpers/application_helper/toolbar/ansible_repositories_center.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class ApplicationHelper::Toolbar::AnsibleRepositoriesCenter < ApplicationHelper::Toolbar::Basic | ||
button_group('ansible_repository', [ | ||
select( | ||
:ansible_repositories_configuration, | ||
'fa fa-cog fa-lg', | ||
t = N_('Configuration'), | ||
t, | ||
:items => [ | ||
button( | ||
:embedded_configuration_script_source_add, | ||
'pficon pficon-edit fa-lg', | ||
t = N_('Add New Repository'), | ||
t, | ||
:url => "/new"), | ||
button( | ||
:embedded_configuration_script_source_edit, | ||
'pficon pficon-edit fa-lg', | ||
t = N_('Edit this Repository'), | ||
t, | ||
:klass => ApplicationHelper::Button::AnsibleRepository, | ||
:onwhen => "1", | ||
:url => "/edit"), | ||
button( | ||
:embedded_configuration_script_source_delete, | ||
'pficon pficon-delete fa-lg', | ||
t = N_('Remove selected Repositories'), | ||
t, | ||
:klass => ApplicationHelper::Button::AnsibleRepository, | ||
:url_parms => "&refresh=y", | ||
:onwhen => "+1", | ||
:confirm => N_("Warning: The selected Repository will be permanently removed!")), | ||
] | ||
) | ||
]) | ||
end |
25 changes: 25 additions & 0 deletions
25
app/helpers/application_helper/toolbar/ansible_repository_center.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class ApplicationHelper::Toolbar::AnsibleRepositoryCenter < ApplicationHelper::Toolbar::Basic | ||
button_group('auth_key_pair_cloud_vmdb', [ | ||
select( | ||
:ansible_repository_configuration, | ||
'fa fa-cog fa-lg', | ||
t = N_('Configuration'), | ||
t, | ||
:items => [ | ||
button( | ||
:embedded_configuration_script_source_edit, | ||
'pficon pficon-edit fa-lg', | ||
t = N_('Edit this Repository'), | ||
t, | ||
:url => "/edit"), | ||
button( | ||
:embedded_configuration_script_source_delete, | ||
'pficon pficon-delete fa-lg', | ||
t = N_('Remove this Repository'), | ||
t, | ||
:url_parms => "&refresh=y", | ||
:confirm => N_("Warning: The selected Repository will be permanently removed!")), | ||
] | ||
), | ||
]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#main_div | ||
%br | ||
%br | ||
|
||
.form-horizontal | ||
%form#form_div{:name => "angularForm", | ||
'ng-controller' => "repositoryFormController as vm", | ||
'ng-show' => "afterGet", | ||
:novalidate => true} | ||
= render :partial => "layouts/flash_msg" | ||
.form-group{"ng-class" => "{'has-error': angularForm.name.$invalid}"} | ||
%label.col-md-2.control-label | ||
= _('Name') | ||
.col-md-8 | ||
%input.form-control{:type => "text", | ||
:name => "name", | ||
"id" => "name", | ||
'ng-model' => "vm.repositoryModel.name", | ||
:maxlength => MAX_NAME_LEN, | ||
:required => "", | ||
:checkchange => true, | ||
"auto-focus" => ""} | ||
%span.help-block{"ng-show" => "angularForm.name.$error.required"} | ||
= _("Required") | ||
.form-group | ||
%label.col-md-2.control-label | ||
= _('Description') | ||
.col-md-8 | ||
%input.form-control{:type => "text", | ||
:name => "description", | ||
"id" => "description", | ||
'ng-model' => "vm.repositoryModel.description", | ||
:checkchange => true} | ||
.form-group | ||
%label.col-md-2.control-label | ||
= _('SCM type') | ||
.col-md-8 | ||
= select_tag('scm_type', | ||
options_for_select([["#{_('git')}", "git"]], 'git'), | ||
"ng-model" => "vm.repositoryModel.scm_type", | ||
"checkchange" => "", | ||
:disabled => true, | ||
"pf-select" => "") | ||
.form-group | ||
%label.col-md-2.control-label | ||
= _('URL') | ||
.col-md-8 | ||
%input.form-control{:type => "url", | ||
:name => "url", | ||
:id => "url", | ||
'ng-model' => "vm.repositoryModel.url", | ||
:required => "", | ||
:checkchange => true} | ||
%span.help-block{"ng-show" => "angularForm.description.$error.required"} | ||
= _("Required") | ||
.form-group | ||
%label.col-md-2.control-label | ||
= _('SCM credentials') | ||
.col-md-8 | ||
= select_tag('scm_credentials', | ||
options_for_select([["#{_('whatever')}", "wharever"]]), | ||
"ng-model" => "vm.repositoryModel.scm_credentials", | ||
"checkchange" => "", | ||
"pf-select" => "") | ||
.form-group | ||
%label.col-md-2.control-label | ||
= _('SCM Branch') | ||
.col-md-8 | ||
%input.form-control{:type => "text", | ||
:name => "branch", | ||
"id" => "branch", | ||
'ng-model' => "vm.repositoryModel.branch", | ||
:checkchange => true} | ||
.form-group | ||
%label.col-md-2.control-label | ||
= _('SCM Update Options') | ||
.col-md-8 | ||
%div | ||
%label | ||
= check_box_tag("clean", "1", false, 'ng-model' => "vm.repositoryModel.clean") | ||
= _('Clean') | ||
%span.fa.fa-info | ||
%div | ||
%label | ||
= check_box_tag("clean", "1", false, 'ng-model' => 'vm.repositoryModel.deleteOnUpdate') | ||
= _('Delete on Update') | ||
%span.fa.fa-info | ||
%div | ||
%label | ||
= check_box_tag("clean", "1", false, 'ng-model' => 'vm.repositoryModel.updateOnLaunch') | ||
= _('Update on Launch') | ||
%span.fa.fa-info | ||
= render :partial => "layouts/angular/x_edit_buttons_angular" | ||
:javascript | ||
ManageIQ.angular.app.value('repositoryId', '#{@record.try(:id) || 'new'}'); | ||
miq_bootstrap('#form_div'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#main_div | ||
= render :partial => 'repository_form' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#main_div | ||
= render :partial => 'repository_form' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1949,6 +1949,9 @@ | |
:get => %w( | ||
download_data | ||
download_summary_pdf | ||
dummy_data | ||
edit | ||
new | ||
show | ||
show_list | ||
), | ||
|