Alloy 1.8.3 transform issues after upgrade / possible new bug? - appcelerator

I have found 2 issues that relate to the upgrade of Alloy to 1.8.3,
I think both are a part of another bug thats been reported regarding transform and data binding, https://jira.appcelerator.org/browse/ALOY-1477
I didn't want to just report it as a bug incase its down to something i'm doing??
1st one, I originally was referencing alloy_id in the transform for a list
but that started produced an error saying alloy_id could not be found, changing it to $model works but not sure if thats how we are supposed to do it now or its part of the above bug?
xml code (part)
<TableViewRow id="categoriesRow" UCATID="{UCATID}"
ParentID="{ParentID}" CategoryID="{CategoryID}" catName= {catName}"
model="$model" hasDetail="{hasDetail}">
<!-- TableViewRow id="categoriesRow" UCATID="{UCATID}"
ParentID="{ParentID}" CategoryID="{CategoryID}" catName="{catName}"
model="{alloy_id}" hasDetail="{hasChildren}"-->
<Label id="rowTitle">{CategoryName}</Label>
</TableViewRow>
The 2nd one is that setting the hasDetail to true or false (a boolean) for a table row to show there is more detail, this works on the iOS app by displaying the little icon fine in all versions so far,
however before the upgrade, validating the reference as a boolean worked, but now you have to reference it as a string
this can't be right??
controller.js code
function transformFunction(model) {
var transform = model.toJSON();
transform.catName = transform.CategoryName;
transform.hasDetail = transform.hasChildren == "0" ? false : true;
return transform;
}
$.winProdCats.addEventListener('click', function(e) {
Ti.API.info('e.row.hasDetail: ' + e.row.hasDetail );
var iHaveBoolean = e.row.hasDetail;
Ti.API.info('iHaveBoolean: ' + iHaveBoolean );
//if(e.row.hasDetail){ //this don't work as a boolean anymore only as a string
if(iHaveBoolean == "true"){
parentID = e.row.CategoryID;
getData();
filterFunction(library);
updateUI();
} else {
Ti.App.fireEvent('app:products:category:selected', {
UCATID : e.row.UCATID,
catName : e.row.catName,
ParentID : e.row.ParentID,
CategoryID : e.row.CategoryID
});
Alloy.Globals.navGroup.closeWindow($.winProdCats);
}
});

an error saying alloy_id could not be found
This is ALOY-1477, fixed in Alloy 1.8.4
//if(e.row.hasDetail){ //this don't work as a boolean anymore only as a string
This is ALOY-1480, fix to be merged for Alloy 1.8.x next week, shipping with AppC CLI 5.3.0 end of April

Related

Setting .SFUI-* fonts in Xamarin appears to correctly use the font extension to convert but still an warning error occurs

My code is setting to use the System font like this:
Current.Resources["Default-Light"] = Device.RuntimePlatform == Device.iOS ?
".SFUI-Light" :
"Roboto-Light.ttf#Roboto-Light";
Current.Resources["Default-Medium"] = Device.RuntimePlatform == Device.iOS ?
".SFUI-Medium" :
"Roboto-Medium.ttf#Roboto-Medium";
Current.Resources["Default-Light"] = Device.RuntimePlatform == Device.iOS ?
".SFUI-Light" :
"Roboto-Light.ttf#Roboto-Light";
Current.Resources["Default-Bold"] = Device.RuntimePlatform == Device.iOS ?
".SFUI-Bold" :
"Roboto-Bold.ttf#Roboto-Bold";
I understand that there's a concern when people use .SFUI-*.
However I also see this extension in the current XF code:
if (family.StartsWith(".SFUI", System.StringComparison.InvariantCultureIgnoreCase))
{
var fontWeight = family.Split('-').LastOrDefault();
if (!string.IsNullOrWhiteSpace(fontWeight) && System.Enum.TryParse<UIFontWeight>(fontWeight, true, out var uIFontWeight))
{
result = UIFont.SystemFontOfSize(size, uIFontWeight);
return result;
}
result = UIFont.SystemFontOfSize(size, UIFontWeight.Regular);
return result;
}
if(result == null)
result = UIFont.FromName(family, size);
if (result != null)
return result;
here:
https://github.com/xamarin/Xamarin.Forms/blob/main/Xamarin.Forms.Platform.iOS/Extensions/FontExtensions.cs
So, why does this message appear?
2020-07-03 00:30:19.911 J.iOS[5130:1664473] CoreText note: Client
requested name ".SFUI-Bold", it will get TimesNewRomanPSMT rather than
the intended font. All system UI font access should be through proper
APIs such as CTFontCreateUIFontForLanguage() or +[UIFont
systemFontOfSize:].
Should the XF iOS extension not have already done the conversion and if that's the case why is the message appearing in the logs?
Bonus question: how can I stop this happening? Can I make my own font extension for this that gets called first.
For reference:
Here is where I am using the fonts:
if(newValue != null && (bool)newValue)
{
DeckGridTemplate deckGridTemplate = bindable as DeckGridTemplate;
deckGridTemplate.TL.FontFamily = (string)Application.Current.Resources["Default-Medium"];
}
else
{
DeckGridTemplate deckGridTemplate = bindable as DeckGridTemplate;
deckGridTemplate.TL.FontFamily = (string)Application.Current.Resources["Default-Regular"];
}
This sounds like a warning that Apple is issuing just to "scary you". There is a similar comment on a GitHub issue about this topic. As you can see, user esenciadev is having the same question. I have tagged him to see if there's any movement on the subject and will reply back here when any. For now, I don't think that this should be an issue, since you are displaying the desired font.
As for the custom code to intersept this behaviour. Unfortunately, you can't write such middleware, since this is deep into Xamarin. You have chosen to not import any fonts and just use the system ones. You can only set the in your xaml/cs and the platform will do the rest - checks, warnings, etc.

request.object.id not returning in afterSave() in Cloud Code

Parse.Cloud.afterSave(function(request) {
var type = request.object.get("type");
switch (type) {
case 'inspiration':
var query = new Parse.Query("Inspiration");
break;
case 'event':
var query = new Parse.Query("Event");
break;
case 'idea':
var query = new Parse.Query("Idea");
break;
case 'comment':
break;
default:
return;
}
if (query) {
query.equalTo("shares", request.object.id);
query.first({
success: function(result) {
result.increment("sharesCount");
result.save();
},
error: function(error) {
throw "Could not save share count: " + error.message;
}
});
}
});
For some reason request.object.id is not returning the object id from the newly created record. I've tested this code out throughly and have isolated it down to the request.object.id variable. I've even successfully ran it with using a pre-existing object ID and it worked fine. Am I using the wrong variable for the object ID?
Thanks in advanced for any help!
Had this exact problem a few weeks ago.
It turned out to be a bug in Parse's newest Javascript SDK. Please have a look at your CloudCode folder - it should contain a global.json file where you can specify the JavaScript SDK version. By default, it states "latest", change it to "1.4.2" and upload your CloudCode folder again.
In case the global.json file is missing in your cloud code folder, please have a look at this thread, where I described how to create it manually.
Thanks for the reply. I found out another work around for this for version 1.6.5. I should probably also mention that my use case for this code is to increment a count column (comments count) when a new relation has been added to a particular record (post).
Instead of implementing an afterSave method on my relation class (comment), I instead implemented a beforeSave method on my class (Post) and used request.object.dirtyKeys() to get my modified columns. From there I check to see if my dirty key was comments and if it is I increment my count column. It works pretty well actually.

How to get rid of forcefully added underscore with timestamp

I'm working on a project with MVC5 and ran into an issue of MVC trying to "help" me, i think. What i'm doing is trying to tidy up views by extracting their javascript without fiddling around with the bundle config.
Messing around with generic loading in the bundle folder would be an option but i'd rather avoid that.
So here's my code, which is working:
public static string GetControllerName(this ControllerBase controller)
{
var name = controller.GetType().Name;
if (name.ToLower().EndsWith("controller"))
return name.Substring(0, name.Length - 10);
return name;
}
public static IHtmlString LoadViewScripts(this HtmlHelper helper)
{
var view = helper.ViewContext.View as RazorView;
if (view != null && !string.IsNullOrEmpty(view.ViewPath))
{
var controllerName = helper.ViewContext.Controller.GetControllerName();
var vPath = string.Format("~/Scripts/View/{0}/{1}.js", controllerName, Path.GetFileName(view.ViewPath));
var realPath = helper.ViewContext.HttpContext.Server.MapPath(vPath);
if (File.Exists(realPath))
{
var urlPath = UrlHelper.GenerateContentUrl(vPath, helper.ViewContext.HttpContext);
var lwrite = File.GetLastWriteTime(realPath);
return new HtmlString(string.Format("<script type='text/javascript' language='javascript' src='{0}?v={1}'></script>", urlPath, lwrite.Ticks));
}
}
return new HtmlString(string.Empty);
}
Result i am passing to src attribute:
http://localhost/AppName/Scripts/View/Map/SelectSite.cshtml.js?v=635569414679160391
What i am getting (network view of firefox):
http://localhost/AppName/Scripts/View/Map/SelectSite.cshtml.js?v=635569414679160391&_=1421342715176
What i am expecting (network view of firefox):
http://localhost/AppName/Scripts/View/Map/SelectSite.cshtml.js?v=635569414679160391
Does anyone know how to stop MVC from "helping" me cache/refresh things in this particular case?
Ok. So it turns out there was 2 reasons why it wasnt working for me.
The kendo property to disable caching which is enabled by default wasn't in the api. Calling it like this fixed my window issue.
content: {
url: targetUrlSiteSelect,
cache : true
}
My additional script tag still contained that the underscore element. I later on found that solution contained within a comment here:
jQuery version 1.5 - ajax - <script> tag timestamp problem
Comment by Blaise:
$.ajaxPrefilter('script', function(options) { options.cache = true; });

Filtering a loaded kml file in OpenLayers

I'm trying to create an interactive search engine (for finding event tickets) of which one of its features is a visual map that shows related venues using OpenLayers. I have a plethora of venues (3000+) in a kml file that I would like to selectively show a filtered subsection of. Below is the code I have but when I try to run it has a JavaScript error. Running firebug and chrome developer tools makes me think that it is not getting passed the parameters I give because it says that the variables are null. However, I cannot figure out why they are not getting passed. Any insight is greatly appreciated.
var map, drawControls, selectControl, selectedFeature, select;
$('#kml').load('venuesComplete.kml');
kml=$('#kml').html();
function showVenues(state, city, venue){
filterStrategy = new OpenLayers.Strategy.Filter({});
var kmllayer = new OpenLayers.Layer.Vector("KML", {
strategies: [filterStrategy,
new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "venuesComplete.kml",
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
})
});
select = new OpenLayers.Control.SelectFeature(kmllayer);
kmllayer.events.on({
"featureselected": onFeatureSelect,
"featureunselected": onFeatureUnselect
});
map.addControl(select);
select.activate();
filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: "",
value: ""
});
function clearFilter(){
filterStrategy.setFilter(null);
}
function setFilter(property, value){
filter.value = value;
filter.property = property;
filterStrategy.setFilter(filter);
}
var vector_style = new OpenLayers.Style();
if(venue!=""){
setFilter('name', venue);
}else if(city!=""){
setFilter('description', city);
}else if(state!=""){
setFilter('description', state);
}
map.addLayer(kmllayer);
function onPopupClose(evt) {
select.unselectAll();
}
function onFeatureSelect(event) {
var feature = event.feature;
var selectedFeature = feature;
var popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
"<h2>"+feature.attributes.name + "</h2>" + feature.attributes.description +'<br>'+feature.attributes,
null,
true,
onPopupClose
);
document.getElementById('venueName').value=feature.attributes.name;
document.getElementById("output").innerHTML=event.feature.id;
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(event) {
var feature = event.feature;
if(feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
delete feature.popup;
}
}
}
function init() {
map = new OpenLayers.Map('map');
var google_map_layer = new OpenLayers.Layer.Google(
'Google Map Layer',
{type: google.maps.MapTypeId.HYBRID}
);
map.addLayer(google_map_layer);
state="";
state+=document.getElementById('stateProvDesc').value;
city="";
city+=document.getElementById('cityZip').value;
venue="";
venue+=document.getElementById('venueName').value;
showVenues(state,city,'Michie Stadium');
map.addControl(new OpenLayers.Control.LayerSwitcher({}));
map.zoomToMaxExtent();
}
IF I UNDERSTAND CORRECTLY, your kml does not load properly. if this is not the case, please disconsider my answer.
it is very important to check if your kml layer was properly loaded. i have a map that loads multiple dynamic (from php) kml layers and it is not uncommon to have a large layer simply not load. when that happens, the operation is aborted, but, as far as openlayers is concerned, the layer was properly loaded.
so i do 2 things: i check if the amount of loaded data meets the expected number of features in my orginal php kml parser (i use a jquery or ajax call for that) and then, in case there is a discrepancy, i try reloading (since this is a loop, i limit it to 5 attempts, so as not to loop infinitely).
check out some of my code here

Jquery datetime picker plugin?

I am using this plugin:
http://tedserbinski.com/jcalendar/index.html
The plugin is supposed to accept a user defined startdate, but I cant manage to get it to work.
This is the header of the js file:
var _drawCalendar = function(dateIn, a, day, month, year) {
var today = new Date();
if (dateIn == undefined) {
// start from this month.
d = new Date(today.getFullYear(), today.getMonth(), 1);
year.val(today.getFullYear());
month.val(today.getMonth()+1);
day.val(today.getDate());
}
else {
// start from the passed in date
d = dateIn;
d.setDate(1);
}
And i am calling the calendar plug with the following line, that actually is missing something. I have tried hundreds of diffrent code snippets, but I have gived up :(
$('fieldset.jcalendar').jcalendar();
Best regards, Joakim
Any particular reason you aren't using the DatePicker that comes with jQuery UI? The page you linked even says that the project has been superceded by jQuery UI.

Resources