Make the work profile the default one when adding Contacts
Signed-off-by: Greta Doci <gretadoci@gmail.com>
This commit is contained in:
parent
40ad45acd7
commit
3f76420306
|
@ -26,6 +26,7 @@ namespace OCA\Contacts\Controller;
|
|||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
// use OCP\IInitialStateService;
|
||||
use OCP\IConfig;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
@ -38,16 +39,20 @@ class PageController extends Controller {
|
|||
|
||||
/** @var IFactory */
|
||||
private $languageFactory;
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
public function __construct(string $AppName,
|
||||
IRequest $request,
|
||||
IConfig $config,
|
||||
// IInitialStateService $initialStateService,
|
||||
IFactory $languageFactory) {
|
||||
parent::__construct($AppName, $request);
|
||||
|
||||
|
||||
$this->appName = $AppName;
|
||||
// $this->initialStateService = $initialStateService;
|
||||
$this->languageFactory = $languageFactory;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,8 +63,13 @@ class PageController extends Controller {
|
|||
*/
|
||||
public function index(): TemplateResponse {
|
||||
$locales = $this->languageFactory->findAvailableLocales();
|
||||
$defaultProfile = $this->config->getAppValue($this->appName, 'defaultProfile', 'HOME');
|
||||
// TODO: use initialStateService once min-version is 16!
|
||||
// $this->initialStateService->provideInitialState($this->appName, 'locales', $locales);
|
||||
return new TemplateResponse('contacts', 'main', ['locales' => json_encode($locales)]); // templates/main.php
|
||||
// $this->initialStateService->provideInitialState($this->appName, 'defaultProfile', $defaultProfile);
|
||||
return new TemplateResponse(
|
||||
'contacts',
|
||||
'main',
|
||||
['locales' => json_encode($locales), 'defaultProfile'=> json_encode($defaultProfile)]); // templates/main.php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import ActionCopyNtoFN from '../components/Actions/ActionCopyNtoFN'
|
|||
import ActionToggleYear from '../components/Actions/ActionToggleYear'
|
||||
import zones from './zones'
|
||||
|
||||
const defaultProfileState = loadState('contacts', 'defaultProfile')
|
||||
const localesState = loadState('contacts', 'locales')
|
||||
const locales = localesState
|
||||
? localesState.map(({ code, name }) => ({
|
||||
|
@ -83,7 +84,7 @@ const properties = {
|
|||
force: 'text',
|
||||
defaultValue: {
|
||||
value: [''],
|
||||
type: ['HOME']
|
||||
type: [defaultProfileState]
|
||||
},
|
||||
options: [
|
||||
{ id: 'HOME', name: t('contacts', 'Home') },
|
||||
|
@ -108,7 +109,7 @@ const properties = {
|
|||
default: true,
|
||||
defaultValue: {
|
||||
value: ['', '', '', '', '', '', ''],
|
||||
type: ['HOME']
|
||||
type: [defaultProfileState]
|
||||
},
|
||||
options: [
|
||||
{ id: 'HOME', name: t('contacts', 'Home') },
|
||||
|
@ -151,7 +152,7 @@ const properties = {
|
|||
default: true,
|
||||
defaultValue: {
|
||||
value: '',
|
||||
type: ['HOME']
|
||||
type: [defaultProfileState]
|
||||
},
|
||||
options: [
|
||||
{ id: 'HOME', name: t('contacts', 'Home') },
|
||||
|
|
|
@ -5,6 +5,7 @@ if (!\OCP\Util::isIe()) {
|
|||
?>
|
||||
|
||||
<input type="hidden" id="initial-state-contacts-locales" value="<?php p(base64_encode($_['locales'])); ?>">
|
||||
<input type="hidden" id="initial-state-contacts-defaultProfile" value="<?php p(base64_encode($_['defaultProfile'])); ?>">
|
||||
|
||||
<?php } else { ?>
|
||||
<div id="app-content">
|
||||
|
@ -15,4 +16,4 @@ if (!\OCP\Util::isIe()) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
|
Loading…
Reference in New Issue