Trigger click event when scrollTo is set
Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
724592d468
commit
99ab3b2bac
|
@ -91,6 +91,7 @@
|
||||||
fileActions: fileActions,
|
fileActions: fileActions,
|
||||||
allowLegacyActions: true,
|
allowLegacyActions: true,
|
||||||
scrollTo: urlParams.scrollto,
|
scrollTo: urlParams.scrollto,
|
||||||
|
openFile: urlParams.openfile,
|
||||||
filesClient: OC.Files.getClient(),
|
filesClient: OC.Files.getClient(),
|
||||||
multiSelectMenu: [
|
multiSelectMenu: [
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -679,12 +679,19 @@
|
||||||
permissions: OC.PERMISSION_READ,
|
permissions: OC.PERMISSION_READ,
|
||||||
icon: '',
|
icon: '',
|
||||||
actionHandler: function (filename, context) {
|
actionHandler: function (filename, context) {
|
||||||
var dir = context.$file.attr('data-path') || context.fileList.getCurrentDirectory();
|
let dir, id
|
||||||
|
if (context.$file) {
|
||||||
|
dir = context.$file.attr('data-path')
|
||||||
|
id = context.$file.attr('data-id')
|
||||||
|
} else{
|
||||||
|
dir = context.fileList.getCurrentDirectory()
|
||||||
|
id = context.objectId
|
||||||
|
}
|
||||||
if (OCA.Files.App && OCA.Files.App.getActiveView() !== 'files') {
|
if (OCA.Files.App && OCA.Files.App.getActiveView() !== 'files') {
|
||||||
OCA.Files.App.setActiveView('files', {silent: true});
|
OCA.Files.App.setActiveView('files', {silent: true});
|
||||||
OCA.Files.App.fileList.changeDirectory(OC.joinPaths(dir, filename), true, true);
|
OCA.Files.App.fileList.changeDirectory(OC.joinPaths(dir, filename), true, true);
|
||||||
} else {
|
} else {
|
||||||
context.fileList.changeDirectory(OC.joinPaths(dir, filename), true, false, parseInt(context.$file.attr('data-id'), 10));
|
context.fileList.changeDirectory(OC.joinPaths(dir, filename), true, false, parseInt(id, 10));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
displayName: t('files', 'Open')
|
displayName: t('files', 'Open')
|
||||||
|
|
|
@ -414,6 +414,32 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(options.openFile) {
|
||||||
|
// Wait for some initialisation process to be over before triggering the default action.
|
||||||
|
_.defer(() => {
|
||||||
|
try {
|
||||||
|
const fileInfo = JSON.parse(atob($('#initial-state-files-openFileInfo').val()))
|
||||||
|
var spec = this.fileActions.getDefaultFileAction(fileInfo.mime, fileInfo.type, fileInfo.permissions)
|
||||||
|
if (spec && spec.action) {
|
||||||
|
spec.action(fileInfo.name, {
|
||||||
|
objectId: fileInfo.id,
|
||||||
|
fileList: this,
|
||||||
|
fileActions: this.fileActions,
|
||||||
|
dir: fileInfo.directory
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var url = this.getDownloadUrl(fileInfo.name, fileInfo.dir, true);
|
||||||
|
OCA.Files.Files.handleDownload(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
OCA.Files.Sidebar.open(fileInfo.path);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to trigger default action on the file for URL: ${location.href}`, error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this._operationProgressBar = new OCA.Files.OperationProgressBar();
|
this._operationProgressBar = new OCA.Files.OperationProgressBar();
|
||||||
this._operationProgressBar.render();
|
this._operationProgressBar.render();
|
||||||
this.$el.find('#uploadprogresswrapper').replaceWith(this._operationProgressBar.$el);
|
this.$el.find('#uploadprogresswrapper').replaceWith(this._operationProgressBar.$el);
|
||||||
|
@ -1320,31 +1346,6 @@
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.triedActionOnce) {
|
|
||||||
var id = OC.Util.History.parseUrlQuery().openfile;
|
|
||||||
if (id) {
|
|
||||||
var $tr = this.$fileList.children().filterAttr('data-id', '' + id);
|
|
||||||
var filename = $tr.attr('data-file');
|
|
||||||
this.fileActions.currentFile = $tr.find('td');
|
|
||||||
var dir = $tr.attr('data-path') || this.getCurrentDirectory();
|
|
||||||
var spec = this.fileActions.getCurrentDefaultFileAction();
|
|
||||||
if (spec && spec.action) {
|
|
||||||
spec.action(filename, {
|
|
||||||
$file: $tr,
|
|
||||||
fileList: this,
|
|
||||||
fileActions: this.fileActions,
|
|
||||||
dir: dir
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var url = this.getDownloadUrl(filename, dir, true);
|
|
||||||
OCA.Files.Files.handleDownload(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.triedActionOnce = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newTrs;
|
return newTrs;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\Share\IManager;
|
use OCP\Share\IManager;
|
||||||
|
use OC\Files\View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ViewController
|
* Class ViewController
|
||||||
|
@ -89,6 +90,8 @@ class ViewController extends Controller {
|
||||||
private $templateManager;
|
private $templateManager;
|
||||||
/** @var IManager */
|
/** @var IManager */
|
||||||
private $shareManager;
|
private $shareManager;
|
||||||
|
/** @var View */
|
||||||
|
protected $fileView;
|
||||||
|
|
||||||
public function __construct(string $appName,
|
public function __construct(string $appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
|
@ -102,7 +105,8 @@ class ViewController extends Controller {
|
||||||
Helper $activityHelper,
|
Helper $activityHelper,
|
||||||
IInitialState $initialState,
|
IInitialState $initialState,
|
||||||
ITemplateManager $templateManager,
|
ITemplateManager $templateManager,
|
||||||
IManager $shareManager
|
IManager $shareManager,
|
||||||
|
View $view
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->appName = $appName;
|
$this->appName = $appName;
|
||||||
|
@ -118,6 +122,7 @@ class ViewController extends Controller {
|
||||||
$this->initialState = $initialState;
|
$this->initialState = $initialState;
|
||||||
$this->templateManager = $templateManager;
|
$this->templateManager = $templateManager;
|
||||||
$this->shareManager = $shareManager;
|
$this->shareManager = $shareManager;
|
||||||
|
$this->fileView = $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,7 +186,7 @@ class ViewController extends Controller {
|
||||||
* @return TemplateResponse|RedirectResponse
|
* @return TemplateResponse|RedirectResponse
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
|
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) {
|
||||||
if ($fileid !== null) {
|
if ($fileid !== null) {
|
||||||
try {
|
try {
|
||||||
return $this->redirectToFile($fileid);
|
return $this->redirectToFile($fileid);
|
||||||
|
@ -330,6 +335,34 @@ class ViewController extends Controller {
|
||||||
$policy->addAllowedFrameDomain('\'self\'');
|
$policy->addAllowedFrameDomain('\'self\'');
|
||||||
$response->setContentSecurityPolicy($policy);
|
$response->setContentSecurityPolicy($policy);
|
||||||
|
|
||||||
|
$user = $this->userSession->getUser();
|
||||||
|
if ($openfile !== null && $user != null) {
|
||||||
|
$uid = $user->getUID();
|
||||||
|
$userFolder = $this->rootFolder->getUserFolder($uid);
|
||||||
|
$node = $userFolder->getById($openfile)[0];
|
||||||
|
|
||||||
|
// properly format full path and make sure
|
||||||
|
// we're relative to the user home folder
|
||||||
|
$isRoot = $node === $userFolder;
|
||||||
|
$path = $userFolder->getRelativePath($node->getPath());
|
||||||
|
$directory = $userFolder->getRelativePath($node->getParent()->getPath());
|
||||||
|
|
||||||
|
// Prevent opening a file from another folder.
|
||||||
|
if ($dir === $directory) {
|
||||||
|
$this->initialState->provideInitialState(
|
||||||
|
'openFileInfo', [
|
||||||
|
'id' => $node->getId(),
|
||||||
|
'name' => $isRoot ? '' : $node->getName(),
|
||||||
|
'path' => $path,
|
||||||
|
'directory' => $directory,
|
||||||
|
'mime' => $node->getMimetype(),
|
||||||
|
'type' => $node->getType(),
|
||||||
|
'permissions' => $node->getPermissions(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ class FilesSearchProvider implements IProvider {
|
||||||
[
|
[
|
||||||
'dir' => dirname($path),
|
'dir' => dirname($path),
|
||||||
'scrollto' => $result->getName(),
|
'scrollto' => $result->getName(),
|
||||||
|
'openfile' => $result->getId(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -58,4 +58,5 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||||
AppSidebar.$mount('#app-sidebar')
|
AppSidebar.$mount('#app-sidebar')
|
||||||
window.OCA.Files.Sidebar.open = AppSidebar.open
|
window.OCA.Files.Sidebar.open = AppSidebar.open
|
||||||
window.OCA.Files.Sidebar.close = AppSidebar.close
|
window.OCA.Files.Sidebar.close = AppSidebar.close
|
||||||
|
window.OCA.Files.Sidebar.setFullScreenMode = AppSidebar.setFullScreenMode
|
||||||
})
|
})
|
||||||
|
|
|
@ -110,6 +110,7 @@ export default {
|
||||||
loading: true,
|
loading: true,
|
||||||
fileInfo: null,
|
fileInfo: null,
|
||||||
starLoading: false,
|
starLoading: false,
|
||||||
|
isFullScreen: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -202,7 +203,10 @@ export default {
|
||||||
'star-loading': this.starLoading,
|
'star-loading': this.starLoading,
|
||||||
active: this.activeTab,
|
active: this.activeTab,
|
||||||
background: this.background,
|
background: this.background,
|
||||||
class: { 'has-preview': this.fileInfo.hasPreview },
|
class: {
|
||||||
|
'has-preview': this.fileInfo.hasPreview,
|
||||||
|
'app-sidebar--full': this.isFullScreen,
|
||||||
|
},
|
||||||
compact: !this.fileInfo.hasPreview,
|
compact: !this.fileInfo.hasPreview,
|
||||||
loading: this.loading,
|
loading: this.loading,
|
||||||
starred: this.fileInfo.isFavourited,
|
starred: this.fileInfo.isFavourited,
|
||||||
|
@ -428,6 +432,14 @@ export default {
|
||||||
this.resetData()
|
this.resetData()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow to set the Sidebar as fullscreen from OCA.Files.Sidebar
|
||||||
|
* @param {boolean} isFullScreen - Wether or not to render the Sidebar in fullscreen.
|
||||||
|
*/
|
||||||
|
setFullScreenMode(isFullScreen) {
|
||||||
|
this.isFullScreen = isFullScreen
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emit SideBar events.
|
* Emit SideBar events.
|
||||||
*/
|
*/
|
||||||
|
@ -460,5 +472,12 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--full {
|
||||||
|
position: fixed !important;
|
||||||
|
z-index: 2025 !important;
|
||||||
|
top: 0 !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue