Skip to content

Commit

Permalink
Feature 649 stage export (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-andrey authored Mar 5, 2020
1 parent ccbb01b commit a0dd1e8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
### Added
* Add stage export.

## [0.14.0-beta02]
### Fixed
Expand Down
32 changes: 32 additions & 0 deletions addon/controllers/fd-setting.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Controller from '@ember/controller';
import $ from 'jquery';
import FdSheetCloseConfirm from '../mixins/fd-sheet-close-confirm';
import FdReadonlyProjectMixin from '../mixins/fd-readonly-project';
import { A } from '@ember/array';
Expand All @@ -7,6 +8,7 @@ import { resolve, reject } from 'rsvp';
import { isNone, isBlank } from '@ember/utils';
import { transliteration } from '../utils/fd-transliteration';
import { set, computed } from '@ember/object';
import { getOwner } from '@ember/application';

import { SimplePredicate, ComplexPredicate } from 'ember-flexberry-data/query/predicate';
import Builder from 'ember-flexberry-data/query/builder';
Expand Down Expand Up @@ -305,5 +307,35 @@ export default Controller.extend(FdSheetCloseConfirm, FdReadonlyProjectMixin, {

adapter.callFunction('StageBackup', data, null, { withCredentials: true });
},

/**
Run project export.
@method actions.export
*/
export() {
const stage = this.get('currentProjectContext').getCurrentStage();
// Import application config\environment.
let appConfig = getOwner(this).factoryFor('config:environment').class;

if (!isNone(appConfig) && !isNone(stage)) {
const backendUrl = appConfig.APP.backendUrl;
const getExportFileUrl = backendUrl + '/stageActions/StageExportFile?projectId=' + stage;

this.get('appState').loading();

$.flexberry.downloadFile({
url: getExportFileUrl,
onSuccess: () => {
this.get('appState').reset();
},
onError: (errorMessage) => {
this.get('appState').reset();
const messageCaption = this.get('i18n').t('forms.fd-setting.project-actions.export-stage-error');
this.get('fdDialogService').showErrorMessage(messageCaption + '\n' + errorMessage);
}
});
}
},
}
});
2 changes: 2 additions & 0 deletions addon/locales/en/forms/fd-setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default {
'rename-stage-button': 'Transliteration',
'rename-stage-text': 'Performing transliteration will change all fields of the field to the stage, which can lead to its breakdown, we recommend that you backup the stage. Do stage transliteration ?',
'backup-stage-button': 'Project backup',
'export-stage-button': 'Project export',
'export-stage-error': 'Stage export error',
},
'generation-settings-caption': 'Generation settings',
'generation-settings': {
Expand Down
2 changes: 2 additions & 0 deletions addon/locales/ru/forms/fd-setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default {
'rename-stage-button': 'Транслитерацию',
'rename-stage-text': 'Выполнение транслитерации изменит все поля поля в стадию что може привести к ее поломке, рекомендуем сделать бэкап стадии. Селать транслитерацию стадии ?',
'backup-stage-button': 'Бэкап проекта',
'export-stage-button': 'Экспорт проекта',
'export-stage-error': 'Ошибка при экспорте стадии',
},
'generation-settings-caption': 'Настройки генерации',
'generation-settings': {
Expand Down
6 changes: 6 additions & 0 deletions app/templates/fd-setting.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@
{{t "forms.fd-setting.project-actions.backup-stage-button"}}
</button>
</div>
<div class="row">
<span>{{t "forms.fd-setting.project-actions.action-stage-caption"}}</span>
<button class="ui button basic {{if readonlyModeProject 'disabled' ''}}" {{action "export"}}>
{{t "forms.fd-setting.project-actions.export-stage-button"}}
</button>
</div>
<div class="row">
<span>{{t "forms.fd-setting.project-actions.delete-stage-caption"}}</span>
<button class="ui button basic {{if readonlyModeProject 'disabled' ''}}" {{action "delete"}}>
Expand Down

0 comments on commit a0dd1e8

Please sign in to comment.