Disable/enable export proejct button

Fix filesystem saving
This commit is contained in:
Jure Grabnar 2018-10-15 21:40:59 +02:00
parent ed16e8d479
commit d50f56e319
3 changed files with 26 additions and 8 deletions

View file

@ -30,6 +30,7 @@
var exportProjectsModal = null; var exportProjectsModal = null;
var exportProjectsModalHeader = null; var exportProjectsModalHeader = null;
var exportProjectsModalBody = null; var exportProjectsModalBody = null;
var exportProjectsBtn = null;
var projectsViewMode = 'cards'; var projectsViewMode = 'cards';
var projectsViewFilter = $('.projects-view-filter.active').data('filter'); var projectsViewFilter = $('.projects-view-filter.active').data('filter');
@ -218,11 +219,10 @@
* Initialize the JS for export projects modal to work. * Initialize the JS for export projects modal to work.
*/ */
function initExportProjectsModal() { function initExportProjectsModal() {
var $exportProjectsBtn = $('#export-projects-button'); exportProjectsBtn.click(function() {
$exportProjectsBtn.click(function() {
// Load HTML to refresh users list // Load HTML to refresh users list
$.ajax({ $.ajax({
url: $exportProjectsBtn.data('export-projects-url'), url: exportProjectsBtn.data('export-projects-url'),
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
@ -339,6 +339,8 @@
exportProjectsModal = $('#export-projects-modal'); exportProjectsModal = $('#export-projects-modal');
exportProjectsModalHeader = exportProjectsModal.find('.modal-title'); exportProjectsModalHeader = exportProjectsModal.find('.modal-title');
exportProjectsModalBody = exportProjectsModal.find('.modal-body'); exportProjectsModalBody = exportProjectsModal.find('.modal-body');
exportProjectsBtn = $('#export-projects-button');
exportProjectsBtn.addClass('disabled');
updateSelectedCards(); updateSelectedCards();
initNewProjectModal(); initNewProjectModal();
@ -361,10 +363,14 @@
if (this.checked && index === -1) { if (this.checked && index === -1) {
$(this).closest('.panel-project').addClass('selected'); $(this).closest('.panel-project').addClass('selected');
selectedProjects.push(projectId); selectedProjects.push(projectId);
exportProjectsBtn.removeClass('disabled');
// Otherwise, if checkbox is not checked and ID is in list of selected IDs // Otherwise, if checkbox is not checked and ID is in list of selected IDs
} else if (!this.checked && index !== -1) { } else if (!this.checked && index !== -1) {
$(this).closest('.panel-project').removeClass('selected'); $(this).closest('.panel-project').removeClass('selected');
selectedProjects.splice(index, 1); selectedProjects.splice(index, 1);
if (selectedProjects.length == 0)
exportProjectsBtn.addClass('disabled');
} }
}); });
@ -530,9 +536,13 @@
// If checkbox is checked and row ID is not in list of selected project IDs // If checkbox is checked and row ID is not in list of selected project IDs
if (this.checked && index === -1) { if (this.checked && index === -1) {
selectedProjects.push(rowId); selectedProjects.push(rowId);
exportProjectsBtn.removeClass('disabled');
// Otherwise, if checkbox is not checked and ID is in list of selected IDs // Otherwise, if checkbox is not checked and ID is in list of selected IDs
} else if (!this.checked && index !== -1) { } else if (!this.checked && index !== -1) {
selectedProjects.splice(index, 1); selectedProjects.splice(index, 1);
if (selectedProjects.length == 0)
exportProjectsBtn.addClass('disabled');
} }
updateDataTableSelectAllCtrl(); updateDataTableSelectAllCtrl();

View file

@ -7,11 +7,14 @@ require 'csv'
class TeamZipExport < ZipExport class TeamZipExport < ZipExport
include StringUtility include StringUtility
has_attached_file :zip_file, # Override path only for S3
path: '/zip_exports/:attachment/:id_partition/' \ if ENV['PAPERCLIP_STORAGE'] == 's3'
':hash/:style/:filename' has_attached_file :zip_file,
validates_attachment :zip_file, path: '/zip_exports/:attachment/:id_partition/' \
content_type: { content_type: 'application/zip' } ':hash/:style/:filename'
validates_attachment :zip_file,
content_type: { content_type: 'application/zip' }
end
def generate_exportable_zip(user, data, type, options = {}) def generate_exportable_zip(user, data, type, options = {})
@user = user @user = user

View file

@ -37,6 +37,7 @@ describe User, type: :model do
it { should have_db_column :invited_by_type } it { should have_db_column :invited_by_type }
it { should have_db_column :invitations_count } it { should have_db_column :invitations_count }
it { should have_db_column :settings } it { should have_db_column :settings }
it { should have_db_column :variables }
it { should have_db_column :current_team_id } it { should have_db_column :current_team_id }
it { should have_db_column :authentication_token } it { should have_db_column :authentication_token }
end end
@ -179,6 +180,10 @@ describe User, type: :model do
it { is_expected.to respond_to(:system_message_email_notification) } it { is_expected.to respond_to(:system_message_email_notification) }
end end
describe 'user variables' do
it { is_expected.to respond_to(:export_vars) }
end
describe '#last_activities' do describe '#last_activities' do
let!(:user) { create :user } let!(:user) { create :user }
let!(:project) { create :project } let!(:project) { create :project }