
{
"welcomeFile": "/webapp/index.html",
"routes": [
{
"path": "/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources"
},
"description": "SAPUI5 Resources"
},
{
"path": "/test-resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources"
},
"description": "SAPUI5 Test Resources"
},
{
"path": "/bpmworkflowruntime",
"target": {
"type": "destination",
"name": "bpmworkflowruntime",
"entryPath": "/workflow-service"
},
"description": "Workflow REST API"
}
],
"sendWelcomeFileRedirect": true
}
sap.ui.getCore().attachInit(function() {
new sap.m.Shell({
app: new sap.ui.core.ComponentContainer({
height : "100%",
name : "qmacro.UntappdRecommendationApproval",
settings : {
componentData : {
startupParameters : {
taskModel : new sap.ui.model.json.JSONModel({
InstanceID : jQuery.sap.getUriParameters().get("InstanceID")
})
}
}
}
})
}).placeAt("content");
});
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"qmacro/UntappdRecommendationApproval/model/models"
], function(UIComponent, Device, models) {
"use strict";
return UIComponent.extend("qmacro.UntappdRecommendationApproval.Component", {
metadata: {
manifest: "json"
},
/**
* The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
* @public
* @override
*/
init: function() {
// call the base component's init function
UIComponent.prototype.init.apply(this, arguments);
// enable routing
this.getRouter().initialize();
// set the device model
this.setModel(models.createDeviceModel(), "device");
// app-wide helper model
this.setModel(models.createAppModel(), "app");
// get task data
var startupParameters = this.getComponentData().startupParameters;
var taskModel = startupParameters.taskModel;
var taskData = taskModel.getData();
var taskId = taskData.InstanceID;
// initialize model
var contextModel = new sap.ui.model.json.JSONModel("/bpmworkflowruntime/rest/v1/task-instances/" + taskId + "/context");
this.setModel(contextModel);
// Ensure we have access to the Inbox API before continuing
// (we don't except when running within the My Inbox context, ie
// when running "for real", rather than in test mode).
if (startupParameters.inboxAPI) {
// get the task description
var appModel = this.getModel("app");
startupParameters.inboxAPI.getDescription("NA", taskId)
.done(function(data){
appModel.setProperty("/taskDescription", data.Description);
})
.fail(function(errorText){
jQuery.sap.require("sap.m.MessageBox");
sap.m.MessageBox.error(errorText, { title: "Error"});
});
//add actions
startupParameters.inboxAPI.addAction({
type: "Accept",
label: "Continue"
}, function(button) {
this._completeTask(taskId, true);
}, this);
}
},
// Taken mostly straight out of the "Book Approval" tutorial for now
_completeTask: function(taskId, approvalStatus) {
var token = this._fetchToken();
$.ajax({
url: "/bpmworkflowruntime/rest/v1/task-instances/" + taskId,
method: "PATCH",
contentType: "application/json",
async: false,
data: JSON.stringify({
status: "COMPLETED",
context: this.getModel().getData()
}),
headers: {
"X-CSRF-Token": token
}
});
this._refreshTask(taskId);
}
,
_fetchToken: function() {
var token;
$.ajax({
url: "/bpmworkflowruntime/rest/v1/xsrf-token",
method: "GET",
async: false,
headers: {
"X-CSRF-Token": "Fetch"
},
success: function(result, xhr, data) {
token = data.getResponseHeader("X-CSRF-Token");
}
});
return token;
},
_refreshTask: function(taskId) {
this.getComponentData().startupParameters.inboxAPI.updateTask("NA", taskId);
}
});
});
sap.ui.define([
"sap/ui/model/json/JSONModel",
"sap/ui/Device"
], function(JSONModel, Device) {
"use strict";
return {
createDeviceModel: function() {
var oModel = new JSONModel(Device);
oModel.setDefaultBindingMode("OneWay");
return oModel;
},
createAppModel: function() {
return new JSONModel({
taskDescription: ""
});
}
};
});
title=Beer Recommendations
appTitle=UntappdRecommendationApproval
abv=% ABV
untappdBeerLink=https://untappd.com/beer/{0}
#XFLD:
rating=Rating
#XFLD:
totalCheckins=Total Checkins
beerAndBrewery={0} by {1}
beerDescription={1}% ABV Rating {2} {0}
<mvc:View
controllerName="qmacro.UntappdRecommendationApproval.controller.Main"
displayBlock="true"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<App id="idAppControl">
<pages>
<Page
binding="{/beer}"
showHeader="false">
<content>
<ObjectHeader
icon="{beer_label}"
title="{beer_name}"
number="{beer_abv}"
numberUnit="{i18n>abv}" >
<statuses>
<ObjectStatus
title="{i18n>rating}"
text="{rating_score}" />
<ObjectStatus
title="{i18n>totalCheckins}"
text="{stats/total_count}" />
</statuses>
<attributes>
<ObjectAttribute text="{brewery/brewery_name}" />
<ObjectAttribute text="{beer_style}" />
<ObjectAttribute
text="{
parts : [
'i18n>untappdBeerLink',
'bid'
],
formatter : 'jQuery.sap.formatMessage'
}"
active="true"
press="onLinkAttributePress" />
</attributes>
</ObjectHeader>
<Text
width="100%"
text="{app>/taskDescription}" />
<List
mode="MultiSelect"
items="{similar/items}">
<items>
<StandardListItem
selected="{_selected}"
icon="{beer/beer_label}"
title="{
parts : [
'i18n>beerAndBrewery',
'beer/beer_name',
'brewery/brewery_name'
],
formatter : 'jQuery.sap.formatMessage'
}"
description="{
parts : [
'i18n>beerDescription',
'beer/beer_style',
'beer/beer_abv',
'rating_score'
],
formatter : 'jQuery.sap.formatMessage'
}" />
</items>
</List>
</content>
</Page>
</pages>
</App>
</mvc:View>
GET {{workflowservice}}/v1/workflow-instances/{{instanceId}}/context
{
"beer": {
"bid": 1868220,
"beer_name": "Subluminal",
"beer_abv": 10,
"stats": {
"total_count": 6731,
"monthly_count": 118
},
"brewery": {
"brewery_name": "Buxton Brewery"
},
"auth_rating": 0,
"wish_list": false,
"media": {
[...]
},
"checkins": {
[...]
},
"similar": {
"count": 5,
"items": [
{
"rating_score": 3.77814,
"beer": {
"bid": 1387819,
"beer_name": "Blueberry Maple Stout",
"beer_abv": 6,
"beer_label": "https://untappd.akamaized.net/site/beer_logos/beer-1387819_a53f2_sm.jpeg"
},
"brewery": {
"brewery_name": "Saugatuck Brewing Company"
}
},
{
"rating_score": 4.3603,
"beer": {
"bid": 2224760,
"beer_name": "Original Maple Truffle Ice Cream Waffle",
"beer_abv": 11.5,
"beer_label": "https://untappd.akamaized.net/site/beer_logos/beer-2224760_0a5e5_sm.jpeg"
},
"brewery": {
"brewery_name": "Omnipollo"
}
},
[...]
]
}
}
}
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("qmacro.UntappdRecommendationApproval.controller.Main", {
onLinkAttributePress : function(oEvent) {
var sBeerId = oEvent.getSource().getModel().getProperty("/beer/bid"),
sUrl = "https://untappd.com/beer/" + sBeerId;
sap.m.URLHelper.redirect(sUrl, true);
}
});
});
startupParameters.inboxAPI.addAction({
type: "Accept",
label: "Continue"
}, function(button) {
this._completeTask(taskId, true);
}, this);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
7 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |