Flutter Search Delegate Architecture (code structure best practices) - search

I am relative new to flutter. I was wondering the proper approach in order to implement an AppBar search by using the Search Delegate in Flutter. I read various articles on how to do that. However, with dummy data (used in examples) and just no real world scenarios (code structure) there is no hustle.
My use case consists of
AppBar (home widget - where the search button exists)
One tab (other widget - having a service call to DB at init)
Another tab (other widget -having a service call to DB at init)
My issue is that I want the search to take place at the results lets say of the first tab. So somehow, I have to pass the values return from the service up to my Home widget and then to search Delegate .
I do not know which is the proper way to do that.
InheritedModel/ InheritedWidget ?
passing via the constructors from one widget to another (then I will have tight widget connections and I do not want that)
Some other way using services ?
if any other solution ?
I want the solution to be scalable (as much as possible), in order to make adjustments at near future or add new functionality.
Thanks in advance for your time.
Update
I tried the InheritedModel/ InheritedWidget. For some reason, when I tried to access the data from the build method in Delegate I was receiving null object for inherited object. Probably, I was doing something wrong...I will keep trying...
Adding an image in order to clarify the problem with my app structure...

Do you already know this tutorial?
https://www.youtube.com/watch?v=Wm3OiFBZ2xI
I think, it is exactly what you need. My App uses Data from the Cloud Firestore and the search function is implemented like the search function in this tutorial. It works very well.

Related

What is the "Fx Functions" in Azure applications Insights? How can you add one?

Recently, I've been working with application insights and building up my queries and understanding. One of the features that I would expect is to define functions outside of the scope of a particular kusto script/query with the intention that the function can be reused from other scripts/queries.
When I started working with it, I had noticed a menu item under the sources that was labeled fx functions and had assumed that this is where I could eventually add my functions. Initially, I saw no UI path to create one and I thought this was due to authorization policies. As I'm now much more comfortable with the Kusto language, I want to break my big scripts into smaller ones but I can't.
I've checked with a private account, where I'm full owner, if I could add one but there no UI path as well. I spoke with our Azure configurators and he as an owner can't find a UI path as well. This doesn't seem to be a result of limited authorization. I've google this and I can't find anything. I've the documentation and there is not mention.
Anyone knows what this is and if it represents a custom functions library how can it be modified? How would you reference it?
Update 1
From an answer provided by #ivan-yang, it seems that I missed this when trying out with my personal account. Apparently, you can save a script as
A query
Private
Shared
A function
When saving as a function, the system creates a reference in the shared queries but with a different icon.
Update:
Correction, I can update the function. When a function and a shared query exist with the same name, then there is a problem. Once I renamed the shared query to something else, I could overwrite the function.
In the application insights -> Logs, in the editor field, you can write a query, then click save -> in the popup window, provide a name like f1, then save as Function. Then you can see the the new function f1 in the "fx Functions":
And as per my test, if you define a custom function and save it, there is no chance to modify it.
Regarding how to reference it, you can use the function like requests / traces, like using union / filter etc.

How can I make Content Items without a CommonPart appear in the content list?

I created a custom Type that has a UserPart attached to it.
According to this issue on GitHub you can't add a CommonPart to content that also has a UserPart because it causes a StackOverflowException but I would still like items of my custom Type to show up in the content list. I already store CreatedUtc and PublishedUtc in the custom PartRecord, can I manually plug these in somewhere?
EDIT: For clarification, my specific scenario is that I am building a public facing Orchard website based on existing data that was used in a private application up to this point. I have a legacy table with user accounts that need to be mapped to Orchard Users but they also represent travel agencies that visitors should be able to browse and that Orchard admins should easily be able to edit and create through the Dashboard. I got the idea to create a TravelAgency type with a UserPart from Sipke's webshop tutorial
Content Types do not require to have a CommonPart to show in the Content List. If i remember properly its done by triggering the Creatable() in your migrations.
Also if you have a UserPart, you could Lazy loaded or just reference it via Foreign Key.
Why would you like something like that to be part of the Content List? I usually keep my business-specific Content Types tucked away in a nice section, so there are easier to visualise and use for users.
There is definitely a bug but as they comment you could extend taxonomies to accomplish your task and keep in mind sometimes changing the Orchard Codebase might fit your purposes, you only have to keep track of your changes when you upgrade next time. I have done it a couple of occasions to fit my projects.
If i remember properly, its been a while.. If you look in the core code where the Content List is created it looks for Creatable() Types. digging even more inside the code, chances are the Query in charge will join the CommonPart, hence your problem. You could easily add another query in the controller and add whatever you are after. The problem though, will be refactoring the rest of actions to accommodate your your type too. Way easier isolating your new Type. had to look at it for you, check this baby: Orchard.Core.Contents.Controllers.AdminController

How Do You Create a Page that Selects and Clones part of a Document Library in Sharepoint 2007?

I am trying to set up a MySite allowing individuals to create and modify multiple projects, each which will contain a partial copy of a master Document Library. I have already created the Library and uploaded the documents, and I have a page on which I have been experimenting with how to do this.
I need to be able to display a list of the documents in the document library, allow the user to select which ones they want, and then when they click on a button, I need to initialize the database with some information about that prjoect, some information about each of the files, and the documents need to be copied to a new location, so that the user can pull them up and edit and save the changes that are specific to the one project. Also we will need to be able to be able to add/remove them through a similar interface after the project has already been created, if possible.
And, unfortunately, anything at all that uses code has been restricted; so, we can't use anything that will require anything to be installed in the GAC, and I can't even use any server-side scripts within the ASPX file. It seems like almost everything I find when I search for "Sharepoint 2007 clone Master Document Library" or the like involves using code.
I have been playing around with things in SharePoint designer for creating the UI, and I figured out how to get a list of the documents to show, although I'm having a hard time duplicating it. It created a <WebPartPages:DataFormWebPart> with a <SharePoint:SPDataSource> in it. However, when I've tried to pull over things like a Data View CheckBoxList to the document list, either it just won't let me drop it (this includes anywhere on the form, not just in the document list), or, as expected actually, it doesn't actually bind to each line of the list. It's not entirely clear to me what to do to create this.
I do get (more or less) that you can bind the controls via the .xslt in the form, but I'm figuring it's got to be simpler than writing them by hand since the designer looks so much like the Visual Studio designer. I am having a very hard time figuring out what exactly to do to get any of the controls to work, though; most of them have the same issue as the CheckBoxList and won't even drop on the form. I'm assuming there's a panel of some type, or some other thing, that I need to add to the form first, but this is so different from what I'm used to that I'm having a hard time even getting my bearings.
So, can someone point me in the right direction here? I'm going to need to be able to create the projects, select the documents, copy them over with some other information into a new project, including creating some items in the database. I have been developing software for a long time, on many different platforms with many different languages, although lately it's mainly been WinForms, with a fair bit of .aspx stuff (but nothing too fancy), and it's never been this hard. I figure there's just something I'm not getting about the model here; like, how do you tell the form you want to use x/y/z control connected to particular datasource? How do you tell sharepoint to create a new location for the files? How can you submit the selected files once you have them to Sharepoint and tell them where to copy to?
Any help would be so appreciated I have been tearing my hair out for days. :)
You might have had a change with SharePoint 2010, as there is a javascript/jQuery programming model, but without that you don't have a realistic of coding what you will need. You may get lucky and be able to call the SharePoint web services using jQuery, but it is going to be a lot of work to get around a "no code" requirement.
Okay, well, I was finally able to get this mostly working, although there are still some issues with displaying the data once I get it back; I will try to update this question once I have a better answer for that.
There's a cool library called SPServices which combines with JQuery to give an interface to the web services for SharePoint 2007. It seems to more or less provide an interface to anything that you need to do to use the web services without a lot of extra work on your part.
For example, to query a document library, I set up a function something like this in a helper class (based upon the examples from the SPServices documentation).
ServiceClass.prototype.getSpecialDocLib = function (onComplete) {
var sc = this;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Special Document Library",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
var outTable = new DocTable();
$(xData.responseXML).find("[nodeName='z:row']").each(function () {
var i;
var outRow = new DocTableRow();
for (i = 0; i < this.attributes.length; ++i) {
outRow.addField(this.attributes[i].localName, this.attributes[i].value);
};
outTable.addRow(outRow);
});
sc.onDocumentListComplete(xData, Status);
if (onComplete != null)
onComplete(resultTable);
}
});
};
For copying a document library from one place to another, I believe you can use Lists.AddList to create it, (not specifically documented in SPServices but is based upon this Web Service call) either from scratch or a template, and I believe you can use the SPServices Copy.CopyIntoItemsLocal method.
Anyway, I seem to be making progress with this so far; I will update and accept this answer once I have a little more experience and time to make sure everything works, but so far I seem to be making progress toward the "no code" goal.

Using theme functions in custom module

This is a pretty specific issue which may not have an elegant answer. I want to share a menu across two sites one Drupal and one not. I'm using a custom module to implement hook_menu_link_alter and want to output a themed menu to a file. There's no discussion on this point, we need to just expose an html file for the other site. I know a brute force way to do this by just looping through and just re-creating what the theming function already does, but I thought maybe there was a way to actually use the theming function directly.
Right now I'm trying...
theme('links', theme('navigation-links', 'menu-name'), array('id' => 'menu-id'));
but am receiving no output. I'm also receiving no errors, which is a bummer. (Note: I'm not 100% that the theming function for navigation-links is actually theme('navigation-links'')).
Any ideas?
(Note: I alos posted this question over at the new Drupal StackExchange site but may remove it as the community isn't there yet)
the theming function for links needs an array of links to theme.
you can use something like:
theme('links', menu_navigation_links('menu-name'));
The function menu_navigation_links() exists in includes/menu.inc and it uses the function menu_tree_page_data() which returns the menu's tree data according to the current page you're viewing.
You can use a similar function called menu_tree_all_data(), but you'll have to do the same manipulations that menu_navigation_links() does on the data it returns. otherwise, you'll still get empty menus.

Can I associate custom metadata with an ALAsset?

I'm building an iPhone app that, among other things, allows the user to take and store photographs associated with locations. I am currently using the ALAssetLibrary to allow the photographs to be stored in Photos and be accessible outside the app (on a computer for instance via the built-in mechanisms). There is not a lot of technical content out there for working with the ALAssetLibrary but from what there is I have managed to cobble together a working version of this. I have had to resort to storing a dictionary of photo URLS in my app and manually detecting if the photo still exists when displaying lists of them because there does not seem to be a way to add custom metadata to an ALAsset.
What I would really like to do is add two custom metadata fields to each asset to provide it with a title and a custom id value that I can use to filter on when enumerating the asset library.
As a secondary task, I'd like the user to be able to update the title metadata.
Can it be done? At this point, I really don't think it can because the API really doesn't seem to provide the necessary methods to get/set custom metadata. I'm hoping against all odds that there is some other aspect to the AssetLibrary framework that I have not yet discovered.
At a minimum, if someone can authoritatively say "NO" then at least others might find this breadcrumb on their own trail of hope and change tack more quickly!
And, having 0 reputation I can't tag it with AssetLibrary :( wow, this day is just going downhill. FML
I've been looking over the documentation and I dont think it is possible to tack on additional fields to the ALAsset object, well you can create your own object or extend theirs but that wont help you when your pulling back assets because you'll need to init yours and populate it then.
Look I know this falls short of a really good answer but I had to try.
The ALAsset class documentation describes a property - customMetadata. This is documented to be an NSDictionary of whatever custom tags you want. Currently, however, it is not implemented in the class (I've raised a bug on Apple's developer site to bring the issue up).

Resources