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
2 changes: 1 addition & 1 deletion cap-notebook/demoapp/app/admin-books/fiori-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ annotate AdminService.Books with @(UI: {
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Chapters}',
ID : 'i18nChapters',
Target : 'chapters/@UI.LineItem#i18nChapters',
Target : 'cHapters/@UI.LineItem#i18nChapters',
},
{
$Type : 'UI.ReferenceFacet',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ sap.ui.define(
};

return ControllerExtension.extend("books.controller.custom", {
isDownloadEnabled: function(oBindingContext, aSelectedContexts) {
if (!aSelectedContexts || aSelectedContexts.length === 0) {
return false;
}
return !aSelectedContexts.some(function(oContext) {
return oContext.getProperty("mimeType") === "application/internet-shortcut";
});
},
onRowPress: function(oContext) {
this.base.editFlow
.invokeAction("AdminService.openAttachment", {
Expand Down Expand Up @@ -90,6 +98,43 @@ sap.ui.define(
},
close: function (closeBtn) {
closeBtn.getSource().getParent().close();
},
onDownloadPress: function(oContext, aSelectedContexts) {
var sIds = aSelectedContexts.map(function (oCtx) {
return oCtx.getObject().ID;
}).join(",");
this.base.editFlow
.invokeAction("AdminService.downloadSelectedAttachments", {
contexts: aSelectedContexts[0],
parameterValues: [{ name: "ids", value: sIds }],
skipParameterDialog: true
})
.then(function (res) {
var sJsonResponse = res.getObject().value;
var aEntries = JSON.parse(sJsonResponse);
aEntries.forEach(function (oEntry) {
if (oEntry.status === "success") {
if (oEntry.linkUrl) {
window.open(oEntry.linkUrl, "_blank");
} else if (oEntry.content) {
var byteString = atob(oEntry.content);
var aBytes = new Uint8Array(byteString.length);
for (var i = 0; i < byteString.length; i++) {
aBytes[i] = byteString.charCodeAt(i);
}
var oBlob = new Blob([aBytes], { type: oEntry.mimeType || "application/octet-stream" });
var sUrl = URL.createObjectURL(oBlob);
var oLink = document.createElement("a");
oLink.href = sUrl;
oLink.download = oEntry.fileName || "download";
document.body.appendChild(oLink);
oLink.click();
document.body.removeChild(oLink);
URL.revokeObjectURL(sUrl);
}
}
});
});
}
});
}
Expand Down
142 changes: 116 additions & 26 deletions cap-notebook/demoapp/app/admin-books/webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"target": "AuthorsDetails"
},
{
"pattern": "Books({key})/chapters({key2}):?query:",
"pattern": "Books({key})/cHapters({key2}):?query:",
"name": "chaptersObjectPage",
"target": "ChaptersObjectPage"
},
Expand Down Expand Up @@ -137,7 +137,7 @@
"attachments/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -147,16 +147,26 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"references/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -166,16 +176,26 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"footnotes/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -185,8 +205,18 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
Expand All @@ -207,7 +237,7 @@
"attachments/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -217,16 +247,26 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"references/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -236,16 +276,26 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"footnotes/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -255,8 +305,18 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
Expand All @@ -278,7 +338,7 @@
"attachments/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -288,16 +348,26 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"references/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -310,13 +380,23 @@
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"footnotes/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"selectionMode": "Multi",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
Expand All @@ -326,8 +406,18 @@
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
"anchor": "StandardAction::Create",
"placement": "After"
}
},
"download": {
"text": "Download",
"requiresSelection": true,
"enabled": ".extension.admin.controller.custom.isDownloadEnabled",
"press": ".extension.admin.controller.custom.onDownloadPress",
"position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
Expand Down
Loading
Loading