瀏覽代碼

Fix accessibility

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
tags/v18.0.0beta1
John Molakvoæ (skjnldsv) 4 年之前
父節點
當前提交
836e7305d0
No account linked to committer's email address

+ 6
- 1
apps/accessibility/appinfo/routes.php 查看文件

@@ -35,7 +35,12 @@ return [
[
'name' => 'Config#setConfig',
'url' => '/api/v1/config/{key}',
'verb' => 'POST',
'verb' => 'PUT',
],
[
'name' => 'Config#deleteConfig',
'url' => '/api/v1/config/{key}',
'verb' => 'DELETE',
],
]
];

+ 1
- 1
apps/accessibility/js/accessibility.js
文件差異過大導致無法顯示
查看文件


+ 1
- 1
apps/accessibility/js/accessibility.js.map
文件差異過大導致無法顯示
查看文件


+ 28
- 10
apps/accessibility/lib/Controller/ConfigController.php 查看文件

@@ -102,16 +102,8 @@ class ConfigController extends OCSController {
public function setConfig(string $key, $value): DataResponse {
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {

if ($value === false) {
$this->config->deleteUserValue($this->userId, $this->appName, $key);
$userValues = $this->config->getUserKeys($this->userId, $this->appName);

// remove hash if no settings selected
if (count($userValues) === 1 && $userValues[0] === 'icons-css') {
$this->config->deleteUserValue($this->userId, $this->appName, 'icons-css');
}

return new DataResponse();
if ($value === false || $value === '') {
throw new OCSBadRequestException('Invalid value: ' . $value);
}

$themes = $this->accessibilityProvider->getThemes();
@@ -133,4 +125,30 @@ class ConfigController extends OCSController {
throw new OCSBadRequestException('Invalid key: ' . $key);
}

/**
* @NoAdminRequired
*
* Unset theme or font config
*
* @param string $key theme or font
* @return DataResponse
* @throws Exception
*/
public function deleteConfig(string $key): DataResponse {
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {

$this->config->deleteUserValue($this->userId, $this->appName, $key);
$userValues = $this->config->getUserKeys($this->userId, $this->appName);

// remove hash if no settings selected
if (count($userValues) === 1 && $userValues[0] === 'icons-css') {
$this->config->deleteUserValue($this->userId, $this->appName, 'icons-css');
}

return new DataResponse();
}

throw new OCSBadRequestException('Invalid key: ' . $key);
}

}

+ 22
- 9
apps/accessibility/lib/Settings/Personal.php 查看文件

@@ -27,10 +27,12 @@ namespace OCA\Accessibility\Settings;
use OCA\Accessibility\AccessibilityProvider;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Settings\ISettings;
use OCP\Util;

class Personal implements ISettings {

@@ -52,6 +54,9 @@ class Personal implements ISettings {
/** @var AccessibilityProvider */
private $accessibilityProvider;

/** @var IInitialStateService */
private $initialStateService;

/**
* Settings constructor.
*
@@ -67,13 +72,15 @@ class Personal implements ISettings {
IUserSession $userSession,
IL10N $l,
IURLGenerator $urlGenerator,
AccessibilityProvider $accessibilityProvider) {
AccessibilityProvider $accessibilityProvider,
IInitialStateService $initialStateService) {
$this->appName = $appName;
$this->config = $config;
$this->userSession = $userSession;
$this->l = $l;
$this->urlGenerator = $urlGenerator;
$this->accessibilityProvider = $accessibilityProvider;
$this->initialStateService = $initialStateService;
}

/**
@@ -81,19 +88,25 @@ class Personal implements ISettings {
* @since 9.1
*/
public function getForm() {
Util::addScript('accessibility', 'accessibility');
Util::addStyle('accessibility', 'style');

$serverData = [
$availableConfig = [
'themes' => $this->accessibilityProvider->getThemes(),
'fonts' => $this->accessibilityProvider->getFonts(),
'highcontrast' => $this->accessibilityProvider->getHighContrast(),
'selected' => [
'highcontrast' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'highcontrast', false),
'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
]
'highcontrast' => $this->accessibilityProvider->getHighContrast()
];

$userConfig = [
'highcontrast' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'highcontrast', false),
'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
];

return new TemplateResponse($this->appName, 'settings-personal', ['serverData' => $serverData]);
$this->initialStateService->provideInitialState($this->appName, 'available-config', $availableConfig);
$this->initialStateService->provideInitialState($this->appName, 'user-config', $userConfig);

return new TemplateResponse($this->appName, 'settings-personal');
}

/**

+ 2
- 1
apps/accessibility/src/Accessibility.vue 查看文件

@@ -118,9 +118,10 @@ export default {
*/
async selectItem(type, id) {
try {
const isDelete = id === ''
await axios({
url: generateOcsUrl('apps/accessibility/api/v1/config', 2) + type,
method: id === '' ? 'DELETE' : 'POST',
method: isDelete ? 'DELETE' : 'PUT',
data: {
value: id
}

+ 0
- 3
apps/accessibility/templates/settings-personal.php 查看文件

@@ -21,9 +21,6 @@
*
*/

script('accessibility', 'accessibility');
style('accessibility', 'style');
?>

<span id="serverData" data-server="<?php p(json_encode($_['serverData']));?>"></span>
<span id="accessibility"></span>

Loading…
取消
儲存