Umbraco 8 - Checkbox (TrueFalse) Always returning False - umbraco

I'm trying to use the Checkbox/TrueFalse to toggle on/off certain parts of content, however it seems that no matter what setting I put the checkbox on, the Value (even parsed as Bool) always returns false.
I'm wondering if theres a property I'm missing, or if I'm somehow just completely doing it wrong.
#if(item.Value<bool>("includeButton")) {
var linkUrl = item.Value<IPublishedContent>("buttonLink").Url;
#item.Value("buttonLabel")
}
I've tried a few different methods, but to no success.
Any help appreciated.
UPDATE
This is a known issue inside Umbraco 8.0
https://github.com/umbraco/Umbraco-CMS/issues/4812

Related

Prevent redundant operations in RxSwift

I'm starting my adventure with RxSwift, having small experience with React in js already. I think that my problem is common, but I'm not sure how to describe it in concise abstract way, so instead I will describe it on the example.
I'm building iOS app showing some charts. The part of interest consist of ChartAreaController, ChartInfoController, both embedded in ChartController. First controller is the area showing some graph(based on rx chartData property), and the second one among others will have a slider for user to restrict show x-value (rx selectedXRange property) which is restricted to be between some min and max. The min/max value is defined by the current chart data.
Behavior when slider change updates chart is defined in ChartController:
override func viewDidLoad() {
super.viewDidLoad()
(...)
chartInfoController.selectedXRange.asObservable()
.subscribe(onNext: { [unowned self] selectedXRange in
(...)
let chartData = self.filterChartData(from: self.rawChartData, in: selectedXRange)
self.chartAreaController.chartData.accept(chartData)
}).disposed(by: disposeBag)
The filterChartData() method just filters out data that is not in the range, but for the sake of the argument we can assume it is very costly and I don't want it to run twice when it is not necessary.
When user changes the chart he or she wants to show, the new data arrives from server (again ChartController):
private func handleNewData(_ rawChartData: ChartData) {
self.rawChartData = rawChartData
guard let allowedXRange = rawChartData.xRange() else { return }
let selectedXRange = chartInfoController.selectedXRange.value
let newSelectedXRange = calculateSelectedXRange(currentSelectedDays: selectedDaysRange, availableDaysRange: daysRange)
let chartData = filterChartData(from: rawChartData, in: selectedXRange)
self.chartInfoController.allowedXRange = allowedXRange //this line is not crucial
self.chartInfoController.selectedXRange.accept(newSelectedXRange)
self.chartAreaController.chartData.accept(rawChartData)
}
So upon new chart data arrival it may be the case that the currently selected xRange must be trimmed because of the new min/max values of the data. So the side effect of the method will be changing the selectedXRange and in turn running the subscription I pasted earlier. So when new data arrives the chartData is updated twice and I don't want it to happen.
Of course I can comment out last line of the handleNewData() method, but I don't like it very much, since main reason for existence of the handleNewData() is to set chartData, and with the line commented out it's goal would be achieved because of the side effect of the method (which is updating the slider). Not acceptable.
To chartData I added throttle anyways, because fast moving slider will result in many updates and this solves my problem partially(chartData updated only once). But as you may remember the filterChartData() method is costly, and this part will still be running twice.
So the one question is, if my general layout of tackling the problem is OK, or should it be handled way different? At this point I came to conclusion that I'm looking for some way of temporary disabling particular subscription on selectedXRange (without damaging other subscriptions to that variable). Temporary meaning:
(...)
//disable subscription
self.chartInfoController.selectedXRange.accept(newSelectedXRange)
self.chartAreaController.chartData.accept(rawChartData)
//enable subscription
(...)
This seem legit to me, since ChartController as an owner of the subscription and changer of the values may want to disable the subscription whenever it suits him(it?).
Does RxSwift support something like this? If not, then I think I can achieve it myself e.g. via bool property in ChartController, or via adding the subscription to separate disposeBag, which I would dispose and then recreate the subscription. But if it's good thing to do? For example bool solution may be prone to be ill handled when there is some error, and dispose/recreate may be somehow costly, and it may be the case that disposal was not intended to be used like that.
Is there a better practice to handle such situations? As I said I think the problem is common so I hope there is a canonical solution to it :) Thanks for any answer, sorry for the lengthy post.
So the one question is, if my general layout of tackling the problem is OK, or should it be handled way different?
A properly written UI input element observable will only fire when the user makes a change to the UI, not when the program makes a change. For example:
textField.rx.text.orEmpty.subscribe(onNext: { print($0) }) will only print a value when the user types in the textField, not when you call textField.text = "foo" or from a binding .bind(to: textfield.rx.text).
If you wrote the ChartInfoController, I suggest you modify it to work the way the other UI elements do. If you didn't write it, submit an issue to the developer/maintainer.
Does RxSwift support something like [temporarily disabling particular subscription]?
It depends on what you mean by "temporarily disabling". It doesn't support silently unsubscribing and resubscribing but there are plenty of operators that will filter out some events they receive while passing others along. For example filter, throttle, debounce, ignoreElements... There's a lot of them that do that.
Is there a better practice to handle such situations?
Then best solution is mentioned above.
When We have multiple subscriptions to the same Observable, it will re-execute for each subscription.
To stop re-execute for each subscription. RxSwift has several operators for this: share(), replay(), replayAll(), shareReplay(), publish(), and even shareReplayLatestWhileConnected().
read more at (RxSwift: share vs replay vs shareReplay)

Umbraco 7.5.1 umbracoNaviHide

To be able to filter out items that should not be rendered with .Where("Visible") I need a property called umbracoNaviHide that returns true or false.
In earlier versions this was added to the Generic tab. However now you cant append to that tab anymore.
How would I accomplish hiding pages now?
Here's my foreach:
#foreach (var Area in Model.Content.Children.Where("Visible"))
{
Here's a statement about it. But I cant find any workaround.
Related Changes Summary - 7.4 beta - Option toCannot add properties to the "Generic properties" tab
Description - In the 7.4 beta it's not possible anymore to add
properties to the "Generic properties" tab. I know this has been done
because properties can be a bit hidden on that tab and usually are
better on a separate tab. But there are situations where the
properties are better on that tab.
You can add that property as a true/false datatype to any tab. However, it's important to note that umbracoNaviHide does not do anything special it is just a magic string, that, when implemented as a true/false datatype, it works with
.Where("Visible").
Personally I don't use it anymore. If I need to cause items to be visible or not then I would name the property more specifically. For example, it is often useful when implementing menus where you want some nodes to be visible but not others. I generally have a Menu tab where one of the properties is a true/false type called Show in menu with an alias of showInMenu.
In code it could be something like below (I have used TypedContentAtXPath to get the parent node of a specific doc type. Of course there are various ways of doing this)
var homeNode = Umbraco.TypedContentAtXPath("//MyHomePageDocType").First();
var menuItems = homeNode.Children.Where(item=>item.GetPropertyValue<bool>("showInMenu"));
foreach(var item in menuItems)
{
// Do your menu stuff here
}
Hope that helps
J
You can create a composition for node visibility with a checkbox to show or hide the menu item. And you can inherit this to the doc types that you do not want to show.
And then you can do
_homeNode.Children.Where(x => !x.GetPropertyValue<bool>("hideInNavigation"));
Hope this helps!

MapItemsControl does not reflect removing of corresponding ItemsSource

Within a UWP-App (Windows 10) I've got a MapControl and I'm using MapItemsControl to deliver an overlay for that map. The ItemsSource of that MapItemsControl (which is an ObservableCollection) is bound via xaml, but is only working in one direction:
Adding items to that collection is working fine and those items are shown in that MapControl too.
Removing items to that collection is working too, but seemingly only within that collection - the visual representation on my MapControl does not react to removing elements. This can lead to infinite adding of items into that map, while no item gets ever removed.
The ObservableCollection gets updated quiet frequentely (via MapControl.ZoomLevelChanged-Event) and gets cleared & repopulated in that process - might that be a problem?
Binding via xaml looks like this:
<maps:MapControl
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
[...]>
<maps:MapItemsControl ItemsSource="{x:Bind Path=MapDirectionOverlay, Mode=OneWay}"/>
</maps:MapControl>
Any suggestions?
Removing items to that collection is working too, but seemingly only within that collection- the visual representation on my MapControl does not react to removing elements.
ObservableCollection represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed. So if you add or remove items, the collection and ItemsSouce of binding should be reflect updated.
Since I don't know how you removing the item, by using remove methods of ObeservableCollection such as Remove,RemoveAt and RemoveItem, they should work well with removing items as well as removing correspondent item in the map.
But if you just set the ObeservableCollection to null will take no effect on the ItemsSouce.In this scenario you need to set the ItemsSouce of MapItemsControl to null manually but which is not recommend.
Since using Clear-Method did not do the trick, I tried using other remove-methods of the ObservableCollection and eventually that worked.
So in the end, this is the workaround I'm using:
private new void Clear()
{
for (int i = this.Count - 1; i >= 0; i--)
{
this.RemoveAt(i);
}
}
After all I still don't get, why a simple Clear would not work, since it still should raise a NotifyCollectionChangedAction. (Correct me if I'm wrong)

How do I get a fail case to pass in Xcode UITests with swift?

Context: Just starting to get into automation. Unfortunately, my only practice app has a changing UI. E.g., I have buttons that are hidden for some users, and shown for others depending on access permission levels.
Goal: What I want to test is when a fail is a pass; that the buttons are indeed absent when they should be. I have overlays and stuff to contend with too, but I think I can extrapolate from a button example once I'm shown how to do it.
Before this section, the login tests have already passed. This person cannot see sometimesHiddenButton, so I need it to pass the fact that it can't find the button, not fail it. How do I tell it to do that? Is there a special kind of assert I can use, or conditionals, or what?
let tablesQuery = app.tables
app.navigationBars["LandingScreen"].buttons["Hamburger"].tap()
tablesQuery.staticTexts["alwaysShownButton"].tap()
app.navigationBars["alwaysAccessibleScreen"].buttons["Hamburger"].tap()
tablesQuery.staticTexts["sometimesHiddenButton"].staticTexts.tap() <-fails
The .exists param is definitely the one you want - I think the problem is that you are calling .exists on .staticTexts instead of on the XCUIElement returned by .staticTexts["sometimesHiddenButton"]
this:
tablesQuery.staticTexts["sometimesHiddenButton"].exists
should return you a boolean you can switch on or make assertions with.
You can check the .existsvalue.
if !tablesQuery.staticTexts["sometimesHiddenButton"].staticTexts.exists {
//do something for users that don't need to see this
} else {
//do something for users that do see the button
}

override system.assignedto value in a transition

I have a rule that in a previous transition sets a default value for the System.AssignedTo.
Now when the state changes, i want to override that value to a different user.
DEFAULT doesn't work, because there is already a value in there. I can't seem to override that value. Anyone know how that is done? I've tried empty then default.. but that field is also REQUIRED so empty throws an error. Regardless that doesn't work either.
In your rule, try a COPY from Value with the value text being a typed name. Or, DEFAULT from currentuser when editing the Work Item Template in VS (if that all makes sense).

Resources