Skip to content

Instantly share code, notes, and snippets.

View sodogan's full-sized avatar
💭
I am waiting for contributions for SAPUI5

Solen Dogan sodogan

💭
I am waiting for contributions for SAPUI5
View GitHub Profile
@sodogan
sodogan / myJSONModel.js
Created January 2, 2022 15:28 — forked from christianjianelli/myJSONModel.js
Extending SAPUI5 JSON Model
jQuery.sap.require("sap.ui.model.json.JSONModel");
sap.ui.model.json.JSONModel.extend("myJSONModel", {
//declare our new method including two new parameters fnSuccess and fnError, our callback functions
loadDataNew: function(sURL, fnSuccess, fnError, oParameters, bAsync, sType, bMerge, bCache){
var that = this;
if (bAsync !== false) {
let's say you add into i18n.properties file
i18n.properties
message= Your viewig product {0}
jQuery.sap.formatMessage will format this
<ObjectAttribute text="{parts:[{path:'i18n>message'},{path:'ProductID'}], formatter: 'jQuery.sap.formatMessage'}"/>
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:f="sap.ui.layout.form">
<List headerText="{i18n>productListTitle}" items="{/ProductSet}">
<ObjectListItem title="{Name}" intro="{ProductID}"
number="{ parts:[{path:'Price'},{path:'CurrencyCode'}], type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false} }"
type="Active" press="onListItemPress" numberUnit="{CurrencyCode}"
numberState="{= ${Price} &gt; 1000 &amp;&amp;${Price} &lt; 1500 &amp;&amp; ${CurrencyCode} ==='USD' ? 'Error' : 'Success' }">
<ObjectAttribute text="{WeightMeasure} {WeightUnit}" visible="{= ${WeightMeasure} > 0 }" title="Weight"/>
<ObjectAttribute text="{Width} x {Depth} x {Height} {DimUnit}" visible="{= ${path:'CurrencyCode'} ==='EUR' ? true: false }"/>
<firstStatus>
<ObjectStatus text="{parts:[{path: 'WeightMeasure'},{path:'WeightUnit'}], formatter: '.formatter.deliveryStatus' }"/>
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:f="sap.ui.layout.form">
<List headerText="{i18n>productListTitle}" items="{/ProductSet}">
<ObjectListItem title="{Name}" intro="{ProductID}"
number="{ parts:[{path:'Price'},{path:'CurrencyCode'}], type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false} }"
type="Active" press="onListItemPress" numberUnit="{CurrencyCode}"
numberState="{= ${Price} &gt; 1000 &amp;&amp;${Price} &lt; 1500 &amp;&amp; ${CurrencyCode} ==='USD' ? 'Error' : 'Success' }"
>
<firstStatus>
<ObjectStatus
text="{Price}"
/*
* Copyright (C) 2009-2019 SAP SE or an SAP affiliate company. All rights reserved.
*/
sap.ui.define(["sap/ui/comp/smartfilterbar/SmartFilterBar"], function(SmartFilterBar){
"use strict";
return SmartFilterBar.extend("retail.pmr.promotionaloffers.utils.controls.BorderlessSmartFilterBar", {
renderer: SmartFilterBar.getMetadata().getRenderer(),
onAfterRendering : function(){
this.$().css({
sap.ui.define([], function() {
"use strict";
return {
/**
* Rounds the currency value to 2 digits
*
* @public
* @param {string} sValue value to be formatted
* @returns {string} formatted currency value with 2 digits
@sodogan
sodogan / obj.js
Created December 16, 2021 11:17
SAPUI5 extended formatter
sap.ui.define([
"sap/ui/base/Object"
], function (BaseObject) {
"use strict";
return BaseObject.extend("com.sodogan.Products.model.formatter.obj", {
/**
* @param {sap.ui.core.UIComponent} oComponent reference to the app's component
*/
@sodogan
sodogan / flutter_basic_app.dart
Last active May 17, 2021 13:16
Flutter basic app
import 'package:flutter/material.dart';
void main() {
runApp(MyMainApp());
}
class MyMainApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
/*
Dart samples:
To copy a list or map
use:
var myList = [...myBaseList];
var myMap = {...myBaseMap};
*/
void main(List<String> args) {
Map<String, String> myBaseMap = <String, String>{}
import 'dart:math' as math;
class Circle {
double _radius;
Circle({double radius=0.0}){
this._radius = radius;
}