mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
Make the data export format selector remember your last setting
Summary: Depends on D18956. Ref T13049. Make the "Export Format" selector sticky. This is partly selfish, since it makes testing format changes a bit easier. It also seems like it's probably a good behavior in general: if you export to Excel once, that's probably what you're going to pick next time. Test Plan: Exported to excel. Exported again, got excel as the default option. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13049 Differential Revision: https://secure.phabricator.com/D18957
This commit is contained in:
parent
5b61f863fd
commit
61b8c12970
3 changed files with 56 additions and 0 deletions
|
@ -2852,6 +2852,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorExportEngineExtension' => 'infrastructure/export/engine/PhabricatorExportEngineExtension.php',
|
||||
'PhabricatorExportField' => 'infrastructure/export/field/PhabricatorExportField.php',
|
||||
'PhabricatorExportFormat' => 'infrastructure/export/format/PhabricatorExportFormat.php',
|
||||
'PhabricatorExportFormatSetting' => 'infrastructure/export/engine/PhabricatorExportFormatSetting.php',
|
||||
'PhabricatorExtendedPolicyInterface' => 'applications/policy/interface/PhabricatorExtendedPolicyInterface.php',
|
||||
'PhabricatorExtendingPhabricatorConfigOptions' => 'applications/config/option/PhabricatorExtendingPhabricatorConfigOptions.php',
|
||||
'PhabricatorExtensionsSetupCheck' => 'applications/config/check/PhabricatorExtensionsSetupCheck.php',
|
||||
|
@ -8288,6 +8289,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorExportEngineExtension' => 'Phobject',
|
||||
'PhabricatorExportField' => 'Phobject',
|
||||
'PhabricatorExportFormat' => 'Phobject',
|
||||
'PhabricatorExportFormatSetting' => 'PhabricatorInternalSetting',
|
||||
'PhabricatorExtendingPhabricatorConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorExtensionsSetupCheck' => 'PhabricatorSetupCheck',
|
||||
'PhabricatorExternalAccount' => array(
|
||||
|
|
|
@ -421,6 +421,13 @@ final class PhabricatorApplicationSearchController
|
|||
$formats = PhabricatorExportFormat::getAllEnabledExportFormats();
|
||||
$format_options = mpull($formats, 'getExportFormatName');
|
||||
|
||||
// Try to default to the format the user used last time. If you just
|
||||
// exported to Excel, you probably want to export to Excel again.
|
||||
$format_key = $this->readExportFormatPreference();
|
||||
if (!isset($formats[$format_key])) {
|
||||
$format_key = head_key($format_options);
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
|
||||
$e_format = null;
|
||||
|
@ -434,6 +441,8 @@ final class PhabricatorApplicationSearchController
|
|||
}
|
||||
|
||||
if (!$errors) {
|
||||
$this->writeExportFormatPreference($format_key);
|
||||
|
||||
$query = $engine->buildQueryFromSavedQuery($saved_query);
|
||||
|
||||
// NOTE: We aren't reading the pager from the request. Exports always
|
||||
|
@ -497,6 +506,7 @@ final class PhabricatorApplicationSearchController
|
|||
->setName('format')
|
||||
->setLabel(pht('Format'))
|
||||
->setError($e_format)
|
||||
->setValue($format_key)
|
||||
->setOptions($format_options));
|
||||
|
||||
return $this->newDialog()
|
||||
|
@ -912,4 +922,32 @@ final class PhabricatorApplicationSearchController
|
|||
return true;
|
||||
}
|
||||
|
||||
private function readExportFormatPreference() {
|
||||
$viewer = $this->getViewer();
|
||||
$export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY;
|
||||
return $viewer->getUserSetting($export_key);
|
||||
}
|
||||
|
||||
private function writeExportFormatPreference($value) {
|
||||
$viewer = $this->getViewer();
|
||||
$request = $this->getRequest();
|
||||
|
||||
if (!$viewer->isLoggedIn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY;
|
||||
$preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
|
||||
|
||||
$editor = id(new PhabricatorUserPreferencesEditor())
|
||||
->setActor($viewer)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContinueOnMissingFields(true);
|
||||
|
||||
$xactions = array();
|
||||
$xactions[] = $preferences->newTransaction($export_key, $value);
|
||||
$editor->applyTransactions($preferences, $xactions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorExportFormatSetting
|
||||
extends PhabricatorInternalSetting {
|
||||
|
||||
const SETTINGKEY = 'export.format';
|
||||
|
||||
public function getSettingName() {
|
||||
return pht('Export Format');
|
||||
}
|
||||
|
||||
public function getSettingDefaultValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue