CategoryBrowser initialselection

Started by JohnZeman, July 22, 2017, 06:46:12 PM

Previous topic - Next topic

JohnZeman

I've been tinkering with the Sample App Selection Dialogs, especially the category browser, and while the dialog comes up so I can browse the categories, I'm not able to get the dialog to have any category initially selected in the dialog.  Below is a slightly modified snippet from the part that opens the category browser dialog, I'm trying to get it to initially select category ID 38128 which is a test category, but no categories seem to be initially selected.

Am I missing something?

                // Allow the user to select one category from the current database
                $('#sel-cat').click(function() {
                    IMatch.categoryBrowser({
                        initialselection: [38128],
                        options: 'default,singlesel' // default options, but force single selection
                    }).then(function(response) {
                        $('#result').text(JSON.stringify(response,null,2));
                    });
                })

Mario

#1
Documentation glitch. I forgot the join. Just use a comma-separated list of ids or a single id:

initialselection: 38128

or

initialselection: '1,2,3'

or

initialselection: [1000,5,38128].join(',')
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

JohnZeman

Thanks Mario but I'm still not having any luck in having an initial category selected.

Mario

Works here. Just tried with


IMatch.categoryBrowser({
    initialselection: '2074,61543',
    options: 'default'
}).then(function(response) {
    $('#result').text(JSON.stringify(response,null,2));
});


The categories must exist, of course. Your ids will be different.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

JohnZeman

Ok, mystery solved and it's red face time.  :-[

Turns out my problem with the category browser initial selection is the same problem I had yesterday when I was unable to modify the C:\ProgramData\photools.com\imatch6\resources\imatchres.xml file which would allow me to assign specific app panels to specific apps.

It was the text editor I was using, NoteTab Pro.

When I edit my apps with Visual Code everything works as it should.

What had me confused for a long time was I thought I was ok using NoteTab as long as I saved my apps in UTF-8 format, but obviously there's more to app editing than that.

Thanks Mario, I've learned an important lesson about JavaScript in IMatch 2017 (many more lessons to be learned no doubt).

Mario

Mhm, strange. Basically you can write Apps using Windows Notepad, the editor is not important. What sometimes gets in the way is the browser cache (IMatch disables the cache for the App Panel to avoid that). If you test your app in an external browser, make sure the cache is disabled. Else the browser may refuse to see the changes you do to your HTML and use the "old" code... browsers love to cache for efficiency.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

JohnZeman

I had been successfully using NoteTab to edit my apps in the

C:\ProgramData\photools.com\imatch6\webroot\user

folder.

It was when I tried to edit an app in the

C:\ProgramData\photools.com\imatch6\webroot\IMatch\samples

folder where I ran into problems.

Now that I know this I've checked the security settings for the two above folders and I have full permissions for the user folder but no permission for the samples folder.

Mario

IMatch creates the User folder with full permissions for users. The Samples and System folders are considered to be read-only, because the contents of these folders is managed by IMatch and its installer. If you want to make changes to a sample app, do this:

1. Copy it into the User folder.
2. Change the "id" and "name" element in the app.json file.

Each app needs its own unique id (any kind of string will do) and using a unique name allows you to find the app copy in the app manager.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Don't worry John... I did the same thing when I was first tinkering with the sample apps...

Mario - does the id in the JSON file need to be something specific or just any unique string that is different than other apps?  I've just been changing the last 2 digits to be unique.. but was curious if it can just be something as simple as the app name?

Thx!

Mario

It can be any string as long it is unique. The App Manager rejects loading apps with identical ids and logs a warning to the log file.
I usually use a GUID because they are globally unique. (from my developer tool, there are also many web sites which allow you to generate a GUID).
For some examples I used the app name and a photools.com prefix. Works as well.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo