mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-12-19 15:18:52 +08:00
Fix exporting of empty folder [SCI-10427] (#7270)
This commit is contained in:
parent
e61d593a0e
commit
3d1907d972
2 changed files with 32 additions and 13 deletions
|
|
@ -326,6 +326,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async exportProjects(event, rows) {
|
async exportProjects(event, rows) {
|
||||||
|
if (event.number_of_projects === 0) {
|
||||||
|
HelperModule.flashAlertMsg(this.i18n.t('projects.export_projects.zero_projects_flash'), 'danger');
|
||||||
|
} else {
|
||||||
this.exportDescription = event.message;
|
this.exportDescription = event.message;
|
||||||
const ok = await this.$refs.exportModal.show();
|
const ok = await this.$refs.exportModal.show();
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|
@ -334,11 +337,12 @@ export default {
|
||||||
project_folder_ids: rows.filter((row) => row.folder).map((row) => row.id)
|
project_folder_ids: rows.filter((row) => row.folder).map((row) => row.id)
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
this.reloadingTable = true;
|
this.reloadingTable = true;
|
||||||
HelperModule.flashAlertMsg(response.data.flash, 'success');
|
HelperModule.flashAlertMsg(response.data.message, 'success');
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
|
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
move(event, rows) {
|
move(event, rows) {
|
||||||
this.objectsToMove = rows;
|
this.objectsToMove = rows;
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ module Toolbars
|
||||||
def export_action
|
def export_action
|
||||||
return unless @items.all? { |item| item.is_a?(Project) ? can_export_project?(item) : true }
|
return unless @items.all? { |item| item.is_a?(Project) ? can_export_project?(item) : true }
|
||||||
|
|
||||||
num_projects = @items.length
|
num_projects = count_of_export_projects
|
||||||
limit = TeamZipExport.exports_limit
|
limit = TeamZipExport.exports_limit
|
||||||
num_of_requests_left = @current_user.exports_left - 1
|
num_of_requests_left = @current_user.exports_left - 1
|
||||||
team = @items.first.team
|
team = @items.first.team
|
||||||
|
|
@ -121,6 +121,7 @@ module Toolbars
|
||||||
icon: 'sn-icon sn-icon-export',
|
icon: 'sn-icon sn-icon-export',
|
||||||
message: message,
|
message: message,
|
||||||
path: export_projects_team_path(team),
|
path: export_projects_team_path(team),
|
||||||
|
number_of_projects: num_projects,
|
||||||
type: :emit
|
type: :emit
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
@ -205,5 +206,19 @@ module Toolbars
|
||||||
type: :link
|
type: :link
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def count_of_export_projects
|
||||||
|
@items.sum do |item|
|
||||||
|
if item.is_a?(Project) && can_export_project?(item)
|
||||||
|
1
|
||||||
|
elsif item.respond_to?(:inner_projects)
|
||||||
|
item.inner_projects.visible_to(@current_user, item.team).count do |project|
|
||||||
|
can_export_project?(project)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue