Skip to content

Commit

Permalink
action for oform - Fill in onlyoffice
Browse files Browse the repository at this point in the history
  • Loading branch information
Antipkin-A committed Dec 7, 2021
1 parent ecedec9 commit fa14b2b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
3 changes: 2 additions & 1 deletion controller/editorapicontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,14 @@ public function config($fileId, $filePath = null, $shareToken = null, $version =
}

$canEdit = isset($format["edit"]) && $format["edit"];
$canFillForms = isset($format["fillForms"]) && $format["fillForms"];
$editable = $version < 1
&& !$template
&& $file->isUpdateable()
&& !$isPersistentLock
&& (empty($shareToken) || ($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE);
$params["document"]["permissions"]["edit"] = $editable;
if (($editable || $restrictedEditing) && $canEdit) {
if (($editable || $restrictedEditing) && $canEdit || $canFillForms) {
$ownerId = null;
$owner = $file->getOwner();
if (!empty($owner)) {
Expand Down
3 changes: 2 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
}
.icon-onlyoffice-open,
.icon-onlyoffice-convert,
.icon-onlyoffice-download {
.icon-onlyoffice-download,
.icon-onlyoffice-fill {
background-image: url("../img/app-dark.svg");
}

Expand Down
33 changes: 25 additions & 8 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,16 @@
if (!config.mime) {
return true;
}
OCA.Files.fileActions.registerAction({
name: "onlyofficeOpen",
displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
mime: config.mime,
permissions: OC.PERMISSION_READ,
iconClass: "icon-onlyoffice-open",
actionHandler: OCA.Onlyoffice.FileClick
});
if (!config.fillForms) {
OCA.Files.fileActions.registerAction({
name: "onlyofficeOpen",
displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
mime: config.mime,
permissions: OC.PERMISSION_READ,
iconClass: "icon-onlyoffice-open",
actionHandler: OCA.Onlyoffice.FileClick
});
}

if (config.def) {
OCA.Files.fileActions.setDefault(config.mime, "onlyofficeOpen");
Expand All @@ -334,6 +336,21 @@
});
}

if (config.fillForms) {
OCA.Files.fileActions.registerAction({
name: "onlyofficeFill",
displayName: t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"),
mime: config.mime,
permissions: OC.PERMISSION_READ,
iconClass: "icon-onlyoffice-fill",
actionHandler: OCA.Onlyoffice.FileClick
});
}

if (config.fillForms) {
OCA.Files.fileActions.setDefault(config.mime, "onlyofficeFill");
}

if (config.saveas && !$("#isPublic").val()) {
OCA.Files.fileActions.registerAction({
name: "onlyofficeDownload",
Expand Down
2 changes: 1 addition & 1 deletion lib/appconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ public function ShareAttributesVersion() {
"docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
"docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "word", "edit" => true, "def" => true, "review" => true, "comment" => true, "saveas" => ["odt", "pdf", "rtf", "txt"] ],
"docxf" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf", "type" => "word", "edit" => true, "def" => true, "saveas" => ["odt", "pdf", "rtf", "txt"] ],
"oform" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform", "type" => "word", "edit" => true, "fillForms" => true, "def" => true ],
"oform" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform", "type" => "word", "fillForms" => true, "def" => true ],
"dot" => [ "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
"dotx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
"epub" => [ "mime" => "application/epub+zip", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
Expand Down

0 comments on commit fa14b2b

Please sign in to comment.