Skip to content

Commit

Permalink
New samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerem Kayacan committed Sep 29, 2021
1 parent be8586d commit 9769263
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/new/create-deep-entity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
onOrderPress: function(oEvent) {
var oViewModel = this.getModel("createView");
oViewModel.setProperty("/page/busy", true);
var aItPoItemSet = oViewModel.getProperty("/data/items").map(function(oItem) {
return {
Matnr: oItem.Matnr,
Menge: this.convertToFloat(oItem.Menge, 2),
Brtwr: this.convertToFloat(oItem.Brtwr, 2),
TaxPercent: oItem.TaxPercent
};
}.bind(this));
var oDocument = {
Application: "SOSPO",
Aedat: oViewModel.getProperty("/data/Aedat"),
Ihrez: oViewModel.getProperty("/data/Ihrez"),
ItPoItemSet: aItPoItemSet
};
this.getView().getModel().create("/IsPoHeadSet", oDocument, {
success: function(oData, oResponse) {
oViewModel.setProperty("/page/editable", false);
this._documentNumber = oData.Ebeln;
this.startUpload();
oViewModel.setProperty("/page/busy", false);
sap.m.MessageToast.show(this.getResourceBundle().getText("savedMessage"));
}.bind(this),
error: function(oError) {
oViewModel.setProperty("/page/busy", false);
}.bind(this)
});

}
16 changes: 16 additions & 0 deletions src/new/function-import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
_getMaterialData: function(sMatnr, oEventSource) {
this.getModel().callFunction("/GetMaterialData", {
method: "POST",
urlParameters: {
"Matnr": sMatnr
},
success: function(oData, response) {
var sPath = this.getItemBindingPath(oEventSource, "itemsTable", "createView");
var oItemData = this.getModel("createView").getProperty(sPath);
oItemData.Maktx = oData.Maktx;
oItemData.Meins = oData.Meins;
this.getModel("createView").refresh(true);
}.bind(this),
error: function(oError) {}.bind(this)
});
}
12 changes: 12 additions & 0 deletions src/new/jquery-delayedcall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
onNewItemPress: function(oEvent) {
var oViewModel = this.getModel("createView");
oViewModel.getData().data.items.push({});
oViewModel.refresh(true);
var aItems = this.byId("itemsTable").getItems();
for (var i = 0; i < aItems.length; i++) {
var oItem = aItems[i];
}
$.sap.delayedCall(500, this, function() {
this.byId("page").scrollToElement(oItem, 200);
});
},
12 changes: 12 additions & 0 deletions src/new/page-scrolltoelement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
onNewItemPress: function(oEvent) {
var oViewModel = this.getModel("createView");
oViewModel.getData().data.items.push({});
oViewModel.refresh(true);
var aItems = this.byId("itemsTable").getItems();
for (var i = 0; i < aItems.length; i++) {
var oItem = aItems[i];
}
$.sap.delayedCall(500, this, function() {
this.byId("page").scrollToElement(oItem, 200);
});
},
61 changes: 61 additions & 0 deletions src/new/responsive-table.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form"
xmlns:core="sap.ui.core" controllerName="co.arteis.sospo.controller.Create" displayBlock="true">
<App>
<pages>
<Page id="page" title="{i18n>title}" showFooter="true" floatingFooter="true" busy="createView&gt;/page/busy" enableScrolling="true"
showNavButton="true" navButtonPress=".onNavButtonPress">
<content>
<Table id="itemsTable" items="{createView>/data/items}" sticky="ColumnHeaders" width="auto" class="sapUiResponsiveMargin"
mode="{= ${createView>/page/editable} ? 'Delete' : 'None' }" delete=".onItemDelete">
<columns>
<Column>
<Text text="{i18n>Matnr}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>Maktx}"/>
</Column>
<Column hAlign="End" minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>Menge}"/>
</Column>
<Column hAlign="End" minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>Brtwr}"/>
</Column>
<Column hAlign="End" minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>TaxPercent}"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Input value="{createView>Matnr}" maxLength="18" editable="{createView>/page/editable}" name="Matnr" showValueHelp="true"
valueHelpRequest=".onValueHelpRequest" change=".onMatnrChange"/>
<Text text="{createView>Maktx}"/>
<Input
value="{path:'createView>Menge', type:'sap.ui.model.odata.type.Decimal', formatOptions:{minFractionDigits:0,maxFractionDigits:2}, constraints:{precision:13,scale:2}}"
description="{createView>Meins}" editable="{createView>/page/editable}"/>
<Input
value="{path:'createView>Brtwr', type:'sap.ui.model.odata.type.Decimal', formatOptions:{minFractionDigits:2,maxFractionDigits:2}, constraints:{precision:14,scale:2}}"
editable="{createView>/page/editable}"/>
<Select selectedKey="{createView>TaxPercent}" editable="{createView>/page/editable}" wrapItemsText="true"
items="{ path: '/EtTaxSet', sorter: { path: 'Percent' } }">
<items>
<core:Item key="{Percent}" text="{Percent} {Text1}"/>
</items>
</Select>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
<footer>
<OverflowToolbar>
<Button text="{i18n>NewOrder}" type="Emphasized" press=".onNewOrderPress" visible="{= !${createView>/page/editable} }"/>
<ToolbarSpacer/>
<Button text="{i18n>NewItem}" press=".onNewItemPress" visible="{createView>/page/editable}"/>
<Button text="{i18n>PlaceOrder}" type="Emphasized" press=".onOrderPress" visible="{createView>/page/editable}"/>
</OverflowToolbar>
</footer>
</Page>
</pages>
</App>
</mvc:View>
6 changes: 6 additions & 0 deletions src/new/table-delete-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
onItemDelete: function(oEvent) {
var sPath = oEvent.getParameter("listItem").getBindingContextPath();
var idx = parseInt(sPath.substring(sPath.lastIndexOf("/") + 1), 10);
this.getModel("createView").getData().data.items.splice(idx, 1);
this.getModel("createView").refresh(true);
}

0 comments on commit 9769263

Please sign in to comment.