Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
sap.ui.define(
[
"sap/ui/core/mvc/ControllerExtension",
"sap/m/library"
"sap/m/library",
"sap/ui/core/format/DateFormat"
],
function (ControllerExtension,library) {
function (ControllerExtension, library, DateFormat) {
"use strict";
const ChangeCategoryEnum = {
created: "Created",
updated: "Changed",
security: "Access"
// Add more mappings as needed
};

return ControllerExtension.extend("books.controller.custom", {
onRowPress: function(oContext) {
Expand All @@ -27,6 +34,63 @@ sap.ui.define(
library.URLHelper.redirect(odataurl, true);

});
},
onChangelogPress: function(oContext, aSelectedContexts) {
var that =this;
this.base.editFlow
.invokeAction("AdminService.changelog", {
contexts: aSelectedContexts
})
.then(function (res) {
console.log("Result",res[0].value.getObject().value);
that.updateChangeLogInPropertiesModel(res[0].value.getObject().value);
});
},
updateChangeLogInPropertiesModel: function (oChangeLogsForObjectResponse) {
const aChangeLogs = [];
const fileName = JSON.parse(oChangeLogsForObjectResponse).filename;
console.log("Filename: ", fileName);
const aChangeLogsObject = JSON.parse(oChangeLogsForObjectResponse)["changeLogs"];
console.log("ChangeLogsObject:\n", aChangeLogsObject);
// Take latest changes at the top
for (let idx = aChangeLogsObject.length - 1; idx >= 0; idx--) {
const oChangeLogEntry = aChangeLogsObject[idx];
const sLastModifiedBy = oChangeLogEntry["user"];
const sChangeType = oChangeLogEntry["operation"];
const sChangeTime = oChangeLogEntry["time"];
let dateTimeFormat = DateFormat.getDateTimeInstance(sap.ui.getCore().getConfiguration().getLocale());
let changedDate = new Date(sChangeTime);
let changedTime = changedDate?dateTimeFormat.format(new Date(changedDate)) : "" ;
const oChangeLog = {
changedOn: changedTime,
changedBy: sLastModifiedBy,
changeType: ChangeCategoryEnum[sChangeType]
};
aChangeLogs.push(oChangeLog);
console.log("ChangeLog:\n", oChangeLog);
}

this.logFragment= this.base.getExtensionAPI().loadFragment({
name: "books.fragments.changelog",
controller: this
});
var that = this;
this.logFragment.then(function (dialog) {
if(dialog){
dialog.attachEventOnce("afterClose", function () {
dialog.destroy();
});
var oModel = new sap.ui.model.json.JSONModel();
oModel.setSizeLimit(100000);
oModel.setData(aChangeLogs);
that.getView().setModel(oModel, "changelog");
dialog.setTitle(fileName);
dialog.open()
}
});
},
close: function (closeBtn) {
closeBtn.getSource().getParent().close();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<core:FragmentDefinition xmlns:core="sap.ui.core"
xmlns:uxap="sap.uxap"
xmlns="sap.m"
>
<Dialog title="Change Log" id = "changelogDialog" resizable="true" contentWidth="50%"
contentHeight="50%" draggable="true" class="sapUiSizeCompact" verticalScrolling="false">
<content>

<IconTabBar
id="idIconTabBarNoIcons"
class="mcmPropertiesSections" isChildPage="true" enableLazyLoading="true" upperCaseAnchorBar="false" stretchContentHeight= "true">
<items>
<IconTabFilter text="Change Log" key="info">
<Table id="idChangeLogTable" items="{path:'changelog>/', templateShareable:false}"
noDataText="{i18n>LoadingData}">
<columns>
<Column demandPopin="true" popinDisplay="Inline" minScreenWidth="Large">
<Text text="Category"/>
</Column>
<Column demandPopin="true" popinDisplay="Inline" minScreenWidth="Large">
<Text text="Changed By"/>
</Column>
<Column demandPopin="true" popinDisplay="Inline" minScreenWidth="Large">
<Text text="Changed On"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{changelog>changeType}"/>
<Text text="{changelog>changedBy}"/>
<Text text="{changelog>changedOn}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</IconTabFilter>
</items>
</IconTabBar>


</content>

<endButton>
<Button text="Close" press=".close" />
</endButton>
</Dialog>
</core:FragmentDefinition>
108 changes: 108 additions & 0 deletions cap-notebook/demoapp/app/admin-books/webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,56 @@
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"references/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"footnotes/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
}
}
Expand All @@ -173,20 +209,56 @@
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"references/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"footnotes/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
}
}
Expand All @@ -208,20 +280,56 @@
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"references/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
},
"footnotes/@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"type": "ResponsiveTable",
"selectionMode": "Auto",
"rowPress": ".extension.books.controller.custom.onRowPress"
},
"actions": {
"changelog": {
"enableOnSelect": "single",
"text": "Change Log",
"requiresSelection": true,
"press": ".extension.books.controller.custom.onChangelogPress",
"command": "COMMON", "position": {
"anchor": "StandardAction::Create",
"placement": "After"
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cap-notebook/demoapp/db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependency>
<groupId>com.sap.cds</groupId>
<artifactId>sdm</artifactId>
<version>1.6.0</version>
<version>1.0.0-RC1</version>
</dependency>
</dependencies>

Expand Down
1 change: 1 addition & 0 deletions cap-notebook/demoapp/db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,4 @@ entity Writers : managed, cuid {
notebooks : Association to many Notebooks
on notebooks.writer = $self;
}

9 changes: 9 additions & 0 deletions cap-notebook/demoapp/srv/admin-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

entity Books.references as projection on my.Books.references
Expand All @@ -40,6 +41,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

entity Books.footnotes as projection on my.Books.footnotes
Expand All @@ -58,6 +60,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

entity Pages.attachments as projection on my.Pages.attachments
Expand All @@ -76,6 +79,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

entity Pages.references as projection on my.Pages.references
Expand All @@ -94,6 +98,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

// Chapters projections
Expand All @@ -113,6 +118,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

entity Chapters.references as projection on my.Chapters.references
Expand All @@ -131,6 +137,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

entity Chapters.footnotes as projection on my.Chapters.footnotes
Expand All @@ -149,6 +156,7 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};

// Pages footnotes projection
Expand All @@ -168,5 +176,6 @@ service AdminService @(requires: ['admin','system-user']) {
@mandatory @assert.format:'^(https?:\/\/)(([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}|localhost)(:\d{2,5})?(\/[^\s]*)?$' @Common.Label:'URL' url: String @UI.Placeholder: 'Example: https://www.example.com'
);
action openAttachment() returns String;
action changelog() returns String;
};
}
2 changes: 1 addition & 1 deletion cap-notebook/demoapp/srv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.sap.cds</groupId>
<artifactId>sdm</artifactId>
<version>1.6.0</version>
<version>1.0.0-RC1</version>
</dependency>


Expand Down
Loading