In Chat-Demo, there is a syntax where the code (https://donejs.com/Guide.html#switch-between-pages) is split into two blocks: one for <chat-messages/> to load whenever page='chat', and another for <chat-home/> for home.
Those two blocks are very similar.
Imagine if there where not two, but, let's say, ten or more different components to load that way (for example, a big menu of options, each one linking to a different page/component).
Do I need to create as many "if" blocks as the number of options in the menu, or there is another more compact way to do this?
The multiple "if" blocks are an easy way to get up and running with an app quickly. However, it does not work well when your app begins to grow. There is a technique that I have used in apps which works really well. I have uploaded a version of the donejs chat demo with my customizations. I suggest you pull it down before reading further:
https://github.com/DesignByOnyx/donejs-with-route-config
There are 3 commits so you can see the changes between each step of the process. The most important parts are in the 3rd commit:
Generate the DoneJS chat app with no modifications: e0398af4c23207d527c054f1fb1ea65b419119a0
Add the home.component and messages component: 56c2202c117049f67ff7dc52b054ad30cc5b71eb
Add route-config, navigation component, dynamic loading, bundling: 4a924693bfd8a3469d69a6ccb5abe8675724e8a9
Description of Commit #3
The last commit contains all of the magic (and the result of many hours of work from my last project). You should start by looking at the src/route-config.js file, as it contains all of the information about routing and dynamic modules for the app. There are a couple things you should know:
The "modules" object is a simple mapping of url-friendly names to the module which they should load. You can rename these however you want.
NOTE: for each item, a separate bundle will be generated during the build process.
const modules = {
'home': '~/home.component',
'messages': '~/messages/messages',
};
The main export is an array of routes which will be registered for your app:
module.exports = [
{ route: '/', nav: 'Home', data: { moduleId: modules.home } },
{ route: '/chat', nav: 'Chat Messages', data: { moduleId: modules.messages } },
];
For each item in the array, there are 3 properties:
route: the parameterized route - you can include parameters like /user/{userId} for dynamic routing as described in the docs.
data: the default data for the route. Whenever the URL matches the route, the default data will be merged onto the app viewmodel. See the moduleId property on the app viewmodel.
nav (optional): if specified, the value will be used to generate a link in the main navigation component.
Related
I already implemented the creation of a document set at library root level. For this I used the following link: Is it possible to create a project documentset using graph API?
I follow the following steps :
1- Retrieve the document library's Drive Id:
GET https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}?$expand=drive
2- Create the folder:
POST https://graph.microsoft.com/v1.0/drives/${library.drive.id}/root/children
The body of the request is the following
{
"name": ${folderName},
"folder": {},
}
3- Get the folder's SharePoint item id:
GET https://graph.microsoft.com/v1.0/sites/${siteId}/drives/${library.drive.id}/items/${folder.id}?expand=sharepointids
4- Update the item in the Document Library so that it updates to the desired Document Set:
PATCH https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}/items/${sharepointIds.listItemId}
I do send the following body to the patch request:
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {}
}
I'm looking now how to create a document set in a specific folder in Sharepoint.
For example, i want to create the following folder structure.
The documents folder is at the library root and I want to create a document set named billing.
documents
|_ billing
|_ 2021
|_11
|_01
|_ document1.pdf
|_ document2.pdf
|_ document3.pdf
|_02
...
|_03
...
|_04
|_10
...
thanks
I'm doing something similar but I'm a little behind you, haven't yet created the Document Set (almost there!), but may I respectfully challenge your approach?
I'm not sure it's a good idea to mix Folders and Document Sets, mainly because a Folder breaks the metadata flow, you could achieve the same results just using Document Sets.
I am assuming that your 'day' in the data structure above is your Document Set (containing document1.pdf, etc.) You might want to consider creating a 'Billing' Document Set and either specifically add a Date field to the Document Set metadata or, perhaps better still, just use the standard Created On metadata and then create Views suitably filtered/grouped/sorted on that date.
This way you can also create filtered views for 'Client' or 'Invoice' or 'Financial Year' or whatever.
As soon as your documents exist in a folder, you can no longer filter/sort/group etc., the document library based on metadata.
FURTHER INFORMATION
I am personally structuring my Sales document library thus:
Name: Opportunity; Content Type: Document Set; Metadata: Client Name, Client Address, Client Contact
Name: Proposal; Content Type: Document; Metadata: Proposal ID, Version
Name: Quote; Content Type: Document; Metadata: Quote ID, Version
Etc...
This way the basic SharePoint view is a list of Opportunities (Document Sets), inside which are Proposals, Quotes etc., but I can also filter the view to just show Proposals (i.e. filter by Content Type), or search for a specific Proposal ID, or group by Client Name, then sort chronologically, or by Proposal ID etc.
I'm just saying that you get a lot more flexibility if you avoid using Folders entirely.
p.s. I've been researching for days now how to create Document Sets with graph, it never occurred to me that it might be a two-step process i.e. create the folder, then patch its content type. Many thanks for your post!!
Just re-read your post and my assumption that the 'day' would be your document set was incorrect. In this case, there would be no benefit having a Document Set containing Folders because the moment a Folder exists in the Document Set, metadata flow stops, and the only reason (well, the main reason*) to use Document Sets in preference to Folders is that metadata flow.
*Document Sets also allow you to automatically create a set of documents based on defined templates.
Is it possible to structure a route that contains dynamic parts in predefined format, such as /[name]-id[id], for example to have routes /bob-id303 or /mary-id205?
What I tried is create a file [name]-id[id].js. Inside getInitialProps I console.log the ctx and it contains
pathname: '/[name]-id[id]',
query: { 'name]-id[id': 'bob-id303' },
asPath: '/bob-id303',
On the other hand, calling the file [[name]]-id[id]].js gives
Failed to reload dynamic routes: Error: Optional route parameters are not yet supported ("[[name]-id[id]]").
I'd like to get the name and id directly, then pass them through initial props to the page. I'm aware I can parse asPath, but is there another way to do this?
You could use /[slug] and then do slug.split("-id"). However you may be better off doing the id alone followed by a fetch for metadata because the name could change and then that url would potentially 404.
I noticed a property in Storybooks Options Docs called selectedPanel which I assume will allow me to pre-select an addon panel.
I'm unclear on how to use it. The example is:
options: { selectedPanel: 'storybook/a11y/panel' }
What I don't understand is where the 'storybook/a11y/panel' string comes from. What if I want to preselect the 'Source' panel?
For anyone looking to default to the knobs panel: selectedPanel: 'storybookjs/knobs/panel' appears to work!
I've encountered the same issue and managed to find out that the panelId can at least be found in the addon's register source code step. For example, I wanted to open Readme tab for certain stories.
I ended up finding the id of the panel in registerWithPanelTitle.js, and then using it with the storiesOf API like this:
.addParameters({
options: { selectedPanel: 'REACT_STORYBOOK/readme/panel' },
})
For a11y, it can be found in constants.ts.
Although, I've searched for those in the distributed node_modules versions in my case.
P.S. If you want to reorder the panels for all of the stories globally, the list that the addons are imported in handles it.
I was using the #storybook/addons-essential in main.js and simply added #storybook/addon-controls to the front of the addons array option, like so:
module.exports = {
addons: ['#storybook/addon-controls', '#storybook/addon-essentials'],
...
}
This puts the controls tab first, which is auto-selected.
I'm just starting out with suitescript, and I was wondering how to get the intellisense to work in suitescript 2.0 on creating a saved search.
I know this is easy to do on the netsuite UI but I would like to learn how to do it in Suitescript. Here is example code below. I'm trying to use ctrl + space to show options on the Customer type. I've tried adding ['N/record'] and it gave me options on records.Type.(here were the options) but I can't get it to give me anything inside the filter single quotes.
define(['N/search'],
function(search) {
var MYsearch = search.create({
type: search.Type.CUSTOMER,
title: 'My Customer search',
filters: ['', '', ''] // here is where i want intellisense
})
as a side question: Does anyone know a good place for suitescript 2.0 questions and answers? stackoverflow seems to be lacking. I'm assuming because it's pretty much brand new.
(I know of all the tutorials on the help center and SuiteAnswers)
Thanks for the help!
UPDATE: It looks like Netsuite 2.0 doesn't like Internal IDs... hope that helps.
I usually just create an array for filters, and another for columns, then add my filters to that array like sovar arrFilters = [];
arrFilters.push(search.createFilter({
name: 'mainline',
operator: search.Operator.IS,
values: ['F']
}));
arrFilters.push(search.createFilter({
name: 'trandate',
operator: search.Operator.WITHIN,
values: 'lastMonth',
}));
var arrColumns = [];
// invoiceid
arrColumns.push(search.createColumn({
name: 'internalid',
join: 'appliedtotransaction'
}));
Then you can just use your
search.create({
type: search.Type.VENDOR_PAYMENT,
filters: arrFilters,
columns: arrColumns
});
Hope this helps.
Download the latest SuiteCloud Developer IDE or the Eclipse Mars version (just make sure you have downloaded SuiteCloud plugin SuiteCloud IDE - http://system.netsuite.com/download/ide/update_e4). With this IDE, you will be able to have API code assist for SuiteScript 1.0. However, there is other setup to enable it for SuiteScript 2.0. Also, this will enable you to have intellesense for native fields.
Then if you want to include custom fields/columns, setup your master password at main menu >Netsuite>Master Password>.
Get the list of your accounts from the production, sandbox, and beta environment. Do this at main menu >Netsuite>Manage Account>. If you will be added to a new customer account later, you need to add it manually by doing this step again to reflect it.
Now, you need to connect your project folder to NetSuite account. But first, check the project setting by right clicking to the project folder>NetSuite>Change Project Settings>. Then, make sure you will be using the correct account.
Then log-in to the account by right clicking the project folder >NetSuite>Log in to Project Account>. Once successfully logged-in.
Finally, right click again the project folder >NetSuite>Sync Script IDs from Account>. Follow the instructions and select record type and fields.
As we all know, Meteor's initial payload sent to the client comprises (in production) a concatenated javascript file containing the Meteor platform, packages, and all templates parsed into Meteor's reactive templating system. Server-side rendering, where the templates are rendered to HTML and sent to the client in the initial payload, is on its way but doesn't have an expected release date yet.
I'm looking for a way to "hack" or approximate server-side rendering given the available functionality in Meteor 0.8.x. Specifically, I want to:
enable the page to render its initial contents without first waiting for the several hundred KB Meteor platform javascript file to be downloaded and parsed.
alternatively, modify Meteor so it only sends the templates it needs to render the initial request in the javascript payload, and fetches the remaining templates once render is complete.
The use case is http://q42.com. I recognise Meteor isn't the best fit for static websites like this one but I want to try and see how far I can get anyway. Right now the Meteor platform JS file is over 600 KB in size (±200 KB gzipped) and I'd like to reduce this size if possible.
Note: I'm aware of and already using Arunoda's fast-render package, which is intended to send data with the initial payload. In this case I want to cut down on time-to-first-render by also getting the templates themselves down faster.
This is a little bit tricky. But there are some things you could do. This may not be the beeest way to do it but it could help you get started somehow.
Meteor is build with many packages as 'default', sometimes some are not needed. You can remove the standard-app-packages and add the packages (that you need and use manually) listed here: https://github.com/meteor/meteor/blob/devel/packages/standard-app-packages/package.js
To cut down the templates you would have to include the bare templates that you use and include the other template's separately and perhaps send down the Template information via a Collection, using a live observer handle to initiate the templates
You would have to 'render' the templates on the server side or store them manually in your collection using Spacebars.compile from the spacebars-compiler package which is a little tricky but you could have it done decently:
This should give you a rough idea, not sure how to get passed the 'eval' bit of it though:
HTML file in /private/template.html
<template name="test">
Hello {{name}}
</template>
JS file in /private/template.js
Template.test.name = function() { return "Bob" }
Server side code
var collection = new Meteor.Collection("templates");
var templateData = Assets.getText("template.html");
var templateJs = Assets.getText("template.js");
var compiled = Spacebars.compile(templateData).toString();
var jsData = templateJs;
collection.insert({templateName:"test", data: templateData, js: templateJs});
Client Side code
collection.find().observeChanges({
added: function(id, fields) {
var template = fields.data,
name = fields.name,
js = fields.js;
Template["name"] = UI.Component.extend({
kind: "name",
render: eval(template),
});
eval(js);
}
});
Then just subscribe to the collection asking for your template and it should exist. If you use iron-router I think (not sure) you could make the subscription wait before the template is rendered so you could have it work.
Again this is just a 'hacky' solution, one thing I personally don't like about it is the use of eval, but javascript needs to run somehow...
You could loop through files in a particular folder using fs = Npm.require('fs') to render each template too.
One alternative would be to inject a 'script' tag calling the compiled js template and template helpers to let the template exist.