Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions settings/Panels/Admin/PersistentLocking.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function getPanel() {
$tmpl = new Template('settings', 'panels/admin/persistentlocking');
$tmpl->assign('defaultTimeout', $this->config->getAppValue('core', 'lock_timeout_default', LockManager::LOCK_TIMEOUT_DEFAULT));
$tmpl->assign('maximumTimeout', $this->config->getAppValue('core', 'lock_timeout_max', LockManager::LOCK_TIMEOUT_MAX));
$tmpl->assign('manualFileLockOnWebUIEnabled', $this->config->getAppValue('files', 'enable_lock_file_action', 'no'));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on a core panel outside of the files app, but references a files app setting.
Is that OK?
I don't know what to do when a settings panel needs to have settings from a mix of core and apps.


return $tmpl;
}
Expand Down
34 changes: 23 additions & 11 deletions settings/js/panels/persistentlocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@ $(document).ready(function() {
$('#persistentlocking input').change(function () {
var currentInput = $(this);
var name = currentInput.attr('name');
var value = currentInput.val();
var isValid = true;
var app = '';
var value = '';

var minRange = currentInput.attr('min');
var maxRange = currentInput.attr('max');
if (name === 'enable_lock_file_action') {
app = 'files';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds code to core settings panel JS that is aware of and manipulates a files app setting.
Is this OK?
How to do it better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe enable_lock_file_action could be moved from files app to core app? Or?

if (this.checked) {
value = 'yes';
} else {
value = 'no';
}
} else {
app = 'core';
value = currentInput.val();
var minRange = currentInput.attr('min');
var maxRange = currentInput.attr('max');

// range validation (mainly for firefox) to prevent saving wrong values
var isValid = true;
if (minRange !== undefined && value < minRange) {
isValid = false;
}
if (maxRange !== undefined && value > maxRange) {
isValid = false;
// range validation (mainly for firefox) to prevent saving wrong values
if (minRange !== undefined && value < minRange) {
isValid = false;
}
if (maxRange !== undefined && value > maxRange) {
isValid = false;
}
}

if (isValid) {
OC.AppConfig.setValue('core', name, value);
OC.AppConfig.setValue(app, name, value);
}
// browser should take care of the visual indication if the value
// isn't in the range
Expand Down
6 changes: 6 additions & 0 deletions settings/templates/panels/admin/persistentlocking.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@
min="0"
value="<?php p($_['maximumTimeout'])?>" />
<br/>
<input type="checkbox" name="enable_lock_file_action" id="manualFileLockOnWebUIEnabled" class="checkbox"
value="1" <?php if ($_['manualFileLockOnWebUIEnabled'] === 'yes') {
print_unescaped('checked="checked"');
} ?> />
<label for="manualFileLockOnWebUIEnabled"><?php p($l->t('Enable manual file locking on the web UI'));?></label>
<br/>
</div>