SAPUI5 SplitApp Master and Detail Page not working - odata

I am trying to create a Detail-Master page using OData service in SAPUI5. Everything works fine in the Master page.
When I clicked on the item on the Master page, it brings down to the Detail page, but I could not get the data in the Detail page.
I have put the alert function to debug in the Detail page. This code will never be executed.
var oList = new sap.m.List({headerText: "Material Details", items:
[
new sap.m.DisplayListItem({label:"Material:",value:"{Material}"}),
new sap.m.DisplayListItem({label:"Material:",value:{
path:"Materials",
formatter:function(iValue){
alert('Here!!');
var test = this.getBindingContext();
console.log('SS:' + test);
var currentdate = new Date();
var datetime = "Last Sync: " + currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " # "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
return currentdate + " sq km";
}
}})
]});
Any idea why? do we need to get the model ?
Herer is the full source code:
https://github.com/ferrygun/SAPUI5

Related

Auto Email Google Form Submissions based on Keywords in a String Cell Value

I'm receiving a gmail from the below code, but NOT the form values that I want to be included. I'm trying have a Google Form (Sheet) send an email to me (a teacher) when a student would type an important or alarming keyword in one of the form's fields (col J).
Picture a Google form with essentially the following fields:
A - Date/time stamp
B - email address collection
C - Name (short answer text)
D - what did you learn or work on yesterday? (long answer text)
E - How are you generally feeling today? (multiple choice)
F - Are you tired today? (multiple choice)
G - Are you stressed out today? (multiple choice)
H - What have you going on today? (bunch of checkboxes)
I - What could be "cool" or "good" about today? (long answer text)
J - (optional) Feel free to tell me anything more (long answer text)
If the student types any alert words, like "die" or "drugs" and so on in the last column (column J), I'd like to get a gmail with a summary of all the info on the row. So far, I've set up a trigger and am only getting a gmail with a subject and message, but the message DOES NOT contain the concatenated vars values.
ALSO, the gmail's subject DOES NOT contain the concatenated studname, which would be helpful. I'm curious how you'd fix this code.
THANK YOU!!
function checkComments(){
var commentsRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2").getRange("J2");
var sheet = SpreadsheetApp.getActive().getSheetByName("Sheet2");
var lastrow = sheet.getLastRow();
var comments = sheet.getRange('J' + lastrow).getValue();
if (comments === '.*drug.*'||'.*die.*'||'.*emotion.*'||'.*suicide.*'||) //many more root key words will be added in here in this |OR| format
{
// Send Alert Email.
var timestamp = sheet.getRange('A' + lastrow).getValue();
var studname = sheet.getRange('C' + lastrow).getValue();
var studemail = sheet.getRange('B' + lastrow).getValue();
var feelings= sheet.getRange('E' + lastrow).getValue();
var tired= sheet.getRange('F' + lastrow).getValue();
var stressed= sheet.getRange('G' + lastrow).getValue();
var studwork = sheet.getRange('H' + lastrow).getValue();
var cool = sheet.getRange('I' + lastrow).getValue();
var results = timestamp + ' \n ' + studname + ' \n ' + studemail + ' \n ' + feelings + ' \n ' + tired + ' \n ' + stressed + ' \n ' + studwork + ' \n ' + cool + ' \n ' + comments;
var emailAddress = 'my email address';
var message = 'Alert from the daily survey!\n' + results;
var subject = 'Daily Survey Alert from ' + studname;
MailApp.sendEmail(emailAddress, subject, message);
}
}```
To match a keyword, replace the
if (comments === '.*drug.*'||'.*die.*'||'.*emotion.*'||'.*suicide.*'||)
with
if(!!comments.match(/drug|die|emotion|suicide/))
I've fixed a bit your code and it seems work for me:
function checkComments() {
var sheet = SpreadsheetApp.getSheetByName('Sheet2');
var lastRow = sheet.getLastRow();
// it works faster when you grab all the row at once
var row = sheet.getRange('A'+lastRow+':J'+lastRow).getValues().flat();
var comments = row[9];
var words = ['drug','die','emotion','suicide'];
if (words.filter(w => comments.includes(w)).length == 0) return;
var emailAddress = 'your#mail.com';
var subject = row[2];
var message = row.join('\n');
MailApp.sendEmail(emailAddress, subject, message);
}
Probably it makes sense to use RegEx to search these words in comments. But I'm not sure if you're ready to dive so deep.

Retain message formatting from Google Spreadsheet email script

We are using a Google Spreadsheet script to send us reformatted email.
Problem: We are wondering if there is a way to retain minimal formatting such as line breaks for the "strEnquirerMessage" cell for the following script.
I have tried including htmlBody somehow but no luck so far. Any help is greatly appreciated. Thank you.
User emails this message in contact form:
Line 1
Line 2
Line 3
We currently receive this in the email from this script: Line 1 Line 2 Line 3
Goal is to receive this:
Line 1
Line 2
Line 3
var strEnquirerName = values[row][1];
var strEnquirerEmail = values[row][2];
var strEnquirerAddress = values[row][3];
var strTopic = values[row][4];
var strEnquirerProducts = values[row][5];
var strEnquirerMessage = values[row][6];
var strMessageBody = "<b>NAME:</b> " + strEnquirerName +
"<br/><br/><b>EMAIL:</b> " + strEnquirerEmail +
"<br/><br/><b>ADDRESS:</b> " + strEnquirerAddress +
"<br/><br/><b>TOPIC:</b> " + strTopic +
"<br/><br/><b>PRODUCTS:</b> " + strEnquirerProducts +
"<br/><br/><b>MESSAGE:</b> " + strEnquirerMessage;
MailApp.sendEmail("your#emailaddress.com", strEnquirerEmail, " Contact form from " + strEnquirerName + " - " + strEnquirerEmail + " Re: " + strTopic, strMessageBody);
Thanks to this post, I have found the answer. Below is the updated line from the above code:
var strEnquirerMessage = values[row][6].replace(/\n/g, '<br>');
Beside the cell value is code to replace Google Spreadsheet's new line character with a line break. Hope this helps others.

JQuery Mobile 1.3.0 Collapsible Nested Lists Not Rendering Properly

I have a JQM page that is inserted dynamically into the DOM and must be regenerated every time, as the data may change. The first time the page is displayed, everything works as it should, but if the user returns to this page later, I have the following rendering problem. Here is the list closed:
Here is the list open on the second viewing of the screen:
I've tried various combinations of $(id-selector).trigger('create'), .remove(), and .empty(), but nothing so far makes the page the second time work like it does on the first.
For what it's worth, since this seems to be a problem with JQM for which I am seeking a workaround, here's the code that builds this list:
var url_base_key = resource.url + '_base';
html += '<div data-role="collapsible-set" data-inset="false" id="per-back-issues">';
if (window.per_info.back_issues.length > 0){
html += '<br /><p><b>' + Label('label_back_issues') + '</b></p>';
for (var i = 0; i < window.per_info.back_issues.length; i++){
var group = window.per_info.back_issues[i];
if (group.issues.length > 0){
html += '<div data-role="collapsible" class="per_group" id="per-group-' + group.group + '"><h2 id="group-label-' + group.group + '">' + group.group + '</h2><ul data-role="listview">';
for(var j = 0; j < group.issues.length; j++){
var issue = group.issues[j];
var url_base = window.orgbase_api[url_base_key];
var url = url_base + issue.formats[0].file;
var id = resource.orgbaseapi_url + '-' + issue.year + '-' + issue.month + '-lit_menu_item';
var item = '<li class="per_item">' + GetPdfLink(resource.id, id, url, GetLongMonth('gregorian', issue.month)) + '</li>'
html += item;
}
html += '</ul></div>';
}
}
}
html += '</div>';
This content is wrapped in a JQM page container
<div id="newsletter" data-role="page" data-theme="b" data-content-theme="b">
<div data-role="header">
Back
<h1>Newsletter</h1>
Home
</div>
...
</div>
and added to the DOM every time with
var new_screen = $(html);
new_screen.appendTo($.mobile.pageContainer);
If I try to do a $('#newsletter').remove() before the appendTo(), the appendTo() doesn't work. I can't use an expand event to force the list to redraw itself because the event fires before the expansion happens.
Ok, the problem seems to be the use of new_screen.appendTo($.mobile.pageContainer) multiple times for the same id. I had tried to remove it using $('#' + id).empty().remove() if it already exists before the appendTo(), but I couldn't add it again (perhaps someone can help me understand why I can't do it this way). So I tried just updating the container if it already exists and that fixed the problem. I'd like to understand how adding the item multiple times led to the results I got.
if ($('#' + id).length > 0){
var html = script + body;
//update existing page container
$(id).html(html);
} else {
var html = '<div id="' + id + '" data-role="page" data-url="' + id
+ '" data-theme="' + theme + '" data-content-theme="' + theme + '" class="screen_section">'
+ script + body + '</div>';
var new_screen = $(html);
//add new page container to DOM
new_screen.appendTo($.mobile.pageContainer);
}

ModelState invalid in KendoUI date sent to ASP MVC

I'm using ASP MVC and KendoUI. Data are sent in json format. I'm getting ModelState error from KendoUI grid update where the according to debugger the ModelState ErrorMessage - "The value '/Date(1361499139623)/' is not valid for FirstAvailableDate."
Here's the print screen of my firebug POST
How to resolve this? I'm currently doing ModelState.Clear(); ...sad...
Most probably the project is missing the "kendo.aspnetmvc.min.js" script.
I ended up formating the date using javascript before posting it back to ASP MVC Controller.
Here's my javascript:
function toISOString(d) {
var year = d.getFullYear();
var month = d.getMonth() + 1;
var date = d.getDate();
return year + '-' + month + '-' + date;
}
function toMVCDateTime(d) {
return d.getUTCFullYear() + '-' + padzero(d.getUTCMonth() + 1) + '-' + padzero(d.getUTCDate()) + 'T' + padzero(d.getUTCHours()) + ':' + padzero(d.getUTCMinutes()) + ':' + padzero(d.getUTCSeconds()) + '.' + pad2zeros(d.getUTCMilliseconds()) + 'Z';
}
$.ajax({
url: "TimeSheet/GetWeeklyHistoricalTimeSheets",
type: "POST",
//data: { date: utcDate.toISOString() },
data: { date: toISOString(utcDate)},
success: function (response) {
htmlFactory(response);
}
});

JQUERY call to Controller Action: String Parameter truncated if containing 'space' character

I have a view that accepts 2 string parameters and 2 date values. User hits search button and they get filtered output to the screen. This all works perfectly well until a user inputs a string with a space. i.e. they can search for 'waste' but not 'waste oil'.
Interestingly, in the latter, the parameter is ok from Javascript before the call is made. But on entering the controller code it goes form being 'waste oil' on client to 'waste'. When this happens the other parameters get set to NULL crashing the system.
I've tried replacing the spaces if present with '#' character then stripping out and putting back in ' ' on the controller side. This is a messy fudge and only appears to work with one parameter.
There must be a simple explanation for this parameter data loss, any comments much appreciated
Not sure a code example is needed but here it is anyway if it help:
My controller header :
public ActionResult IndexSearch(int? page, string searchText,string searchTextSite,string StartDate,string EndDate)
{
My HTML Javascript :
function Search(sSearchText,sSite) {
sSearchText = sSearchText.toString().replace(" ", "#");
sSite = sSite.toString().replace(" ", "#");
debugger;
alert($("#AbsolutePath").val() + "Waste.mvc/IndexSearch?searchText=" + sSearchText + "&searchTextSite=" + sSite + "&StartDate=" + $('#StartDate').val() + "&EndDate=" + $('#EndDate').val());
$("#ResultsList").load($("#AbsolutePath").val() + "Waste.mvc/IndexSearch?searchText=" + sSearchText + "&searchTextSite=" + sSite + "&StartDate=" + $('#StartDate').val() + "&EndDate=" + $('#EndDate').val(),
function() {
$('#LoadingGif').empty();
});
$('#LoadingGif').empty().html('<img src="' + $("#AbsolutePath").val() + 'Content/images/ajax-loader.gif" alt="Loading image" />');
}
You are not URL encoding your parameters when sending the AJAX request because you are using string concatenations when building the url. You could use the following technique in order to have properly encoded values:
var url = $('#AbsolutePath').val() + 'Waste.mvc/IndexSearch';
var data = {
searchText: sSearchText,
searchTextSite: sSite ,
StartDate: $('#StartDate').val(),
EndDate: $('#EndDate').val()
};
$('#ResultsList').load(url, data, function() {
$('#LoadingGif').empty();
});
Now you will get correct values on the server.

Resources