netcreateorg / netcreate-2018

Please report bugs, problems, ideas in the project Issues page: https://github.com/netcreateorg/netcreate-2018/issues
Other
11 stars 2 forks source link

Add `provenance` and `comments` Fields #252

Closed benloh closed 1 year ago

benloh commented 1 year ago

This pull request adds the provenance and comments fields.

See the issues for details on implementation.

Both fields have now been added to the base template-schema.js. We can now also generate a new default template JSON from the template-schema.js. Both fields can be added to filters (this came for free with our template-schema implementation).

If you open a project that did not have these fields defined, the project will gracefully open with no errors and by default hide the fields. If you want them on, edit the template to unhide them.

jdanish commented 1 year ago

Nice!! Looking good so far! A few minor notes:

More To Do

BL Adding more to do items to this comment so that it's all in one place.

jdanish commented 1 year ago

If we want to change the default text for provenance and comments, should we edit template-schema (in a separate branch and then merge request)?

benloh commented 1 year ago

If we want to change the default text for provenance and comments, should we edit template-schema (in a separate branch and then merge request)?

You'll want to edit the template-schema.js and also _default.template.toml files. Probably safer to do it in a branch off of this branch in case I need to touch those while fixing the bugs you reported.

jdanish commented 1 year ago

If we want to change the default text for provenance and comments, should we edit template-schema (in a separate branch and then merge request)?

You'll want to edit the template-schema.js and also _default.template.toml files. Probably safer to do it in a branch off of this branch in case I need to touch those while fixing the bugs you reported.

Makes sense and we can wait until this is locked down but figured I’d ask! Thanks!!

benloh commented 1 year ago

Some changes to the default template. Excerpts from the wiki:


https://github.com/netcreateorg/netcreate-2018/wiki/Using-Templates/

Templates and New Projects

_default.template.toml

_default.template.toml is used as the starting point for any new template file. If a dataset is requested that does not already have a template file, it is cloned from _default.template.toml. So you can use this to define a starting point for projects. Use this to set stuff like default node and edge types, common feature parameters etc. The defaults established in the _default.template.toml file can differ from those set by template-schema.js, and will in fact override those in template-schema.js.

template-schema.js

template-schema.js defines the core format of the template toml file. It lists ALL available parameters, sets some json-editor-specific settings, and has help text. This is the source of truth for templates.

This should not be touched by anyone but developers!!!

See [SCHEMA](https://github.com/netcreateorg/netcreate-2018/pull/252#schema), below, for more information.


Default "No Type Selected" Type

A blank label will set the default "No Type Selected" type color. If this is missing, just add a new type with a blank label. Note that the order of the types is the order they will be displayed in the LEGEND/KEY, so move them up/down as you want.

Extra blank labels will be removed when the template is saved. Only the first blank is kept.


Updating _default.template.toml

If you change the template-schema.js the _default.template.toml will no longer reflect the settings in the schema. If you want _default.template.toml to match the settings in template-schema.js, you need to regenerate the _default.template.tom file.

This is easy to do with with a browser.

  1. Start Net.Create
  2. In a browser window"
    1. load the app
    2. open a developer console
    3. enter ncRegenerateDefaultTemplate()

This will generate a new _default.template.toml file in /build/public/templates/_default.template.toml. You can then copy this to any new installs.


benloh commented 1 year ago

Testing template-schema.js and _default.template.toml

How to test that changes to template.schema.js make it all the way through to _default.template.toml.

  1. Edit template-schema.js
    1. Change the default color for the blank "No Type Selected" node type
      1. Around line 84 for the color property, change default: '#eeeee' to default: #ff0000
      2. Save the file
  2. Quit and Start Net.Create (./nc.js --dataset=test) to load the new schema.
  3. Open a browser and go to localhost:3000
  4. Open the developer console
  5. Type ncRegenerateDefaultTemplate()
  6. This should generate a new _default.template.toml file.
  7. Open build/app/assets/templates/_default.template.toml and check around line 44, you should see
    [[nodeDefs.type.options]]
    color = "#ff0000"
  8. In the terminal, ctrl-c to quit Net.Create
  9. Create a new database: ./nc.js --dataset=newdefault -- this should create a new db from the updated default template file.
  10. Open a browser and go to localhost:3000
  11. You should see 'No Type Selected' for nodes are now red.
  12. Click "More... > Edit Template"
  13. Click "Edit Node Types"
  14. The blank type should be red.
jdanish commented 1 year ago

Quick thought - is there an easy way, that isn't a waste of time, to modify the comment filter so that we can say something like "if it is not empty"? Long-term that'll be a badge, but checking for non-empty or empty fields feels useful. But not if it is a distraction. @benloh

jdanish commented 1 year ago

Standalone appears to work, though I'll keep banging on it.

jdanish commented 1 year ago

The provenance and comments fields appear to show up in the table view but clicking on them does not sort the data the way the other tabs do.

jdanish commented 1 year ago

The notes field is now a bit narrow ... not sure how we want to solve that long-term, though?

I had been thinking a full table module / plugin would be nice to let people re-size columns but easier said than done I presume?

benloh commented 1 year ago

modify the comment filter so that we can say something like "if it is not empty"? Long-term that'll be a badge, but checking for non-empty or empty fields feels useful.

@jdanish I think we can easily add a new test for strings.

The provenance and comments fields appear to show up in the table view but clicking on them does not sort the data the way the other tabs do.

It seems to work for me. Are you sure it's broken? Can you tell me how to reproduce or show me a video?

The notes field is now a bit narrow ... not sure how we want to solve that long-term, though?

I didn't really touch the styling on the table at all. We might consider making the tables the full width of the browser to give them more room. We could also style the text a little more (e.g. Provenance can be smaller. The text in general could probably be smaller.

I didn't want to touch the styling without checking in with you first. Do you want to take a crack at it and style it as I see fit? Or did you want to talk through the changes?

I had been thinking a full table module / plugin would be nice to let people re-size columns but easier said than done I presume?

This really depends on whether we can find the right library. In the past, we had issues with libraries not working well with React, or being a pain in the tuchus to implement. If this is significant enough of an issue, add it to the issues db and we can prioritize.

jdanish commented 1 year ago

The provenance and comment sorting do appear to work now. Prior issue may have been an artifact of sparse population in the sense that it worked but I couldn't tell.

Re: styling, do what you need, but the big overhaul should wait until we have more change done and should do a round together at that time.

Re: table ... let's revisit when we look at the long-term timeline etc.

benloh commented 1 year ago

Added "is empty" and "is not empty"

benloh commented 1 year ago

Provenance and Comment now sort properly for v1.3-era projects that have been only partially migrated to the current version. The issue was that provenance and comments fields were undefined so nothing was ever sorted. We had to introduce "typing" so that we know how to sort the data and catch undefined data. This also addresses #247 .

benloh commented 1 year ago

@jdanish this ended up expanding to many other issues/fixes, but I think we should be able to merge and close this now? We'll handle the other issues in another branch/merge?

jdanish commented 1 year ago

@benloh Ready to merge! Only last minor thing is that the yellow on the comments on nodes table (awesome) isn't also on edges. I'd say merge it once that is in, though!

jdanish commented 1 year ago

Oh, one minor catch @benloh - provenance needs to be slightly wider to keep the arrow visible.

Screenshot 2023-05-29 at 7 57 18 PM
benloh commented 1 year ago
benloh commented 1 year ago

Merging and closing.