All files / app/mods/org grid.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104118x       118x                                                                                                                                                                                           118x          
import { DateTime } from 'luxon';
import { Mod } from '../../model/tag';
import { Template } from '../../model/template';
 
export const gridTemplate: Template = {
  tag: 'grid',
  name: $localize`☰ Grid`,
  config: {
    mod: $localize`☰ Grid`,
    type: 'lens',
    experimental: true,
    global: true,
    view: $localize`☰`,
    tab: $localize`grid`,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    submit: $localize`☰ grid/`,
    description: $localize`Activates built-in grid viewer mode for viewing Refs.`,
    filters: [
      { query: 'grid', label: $localize`☰ grid`, group: $localize`Templates 🎨️` },
    ],
    form: [{
      key: 'columnDefs',
      type: 'list',
      props: {
        label: $localize`Columns:`,
        addText: $localize`+ Add another column`,
      },
      fieldArray: {
        fieldGroup: [{
          key: 'headerName',
          type: 'string',
          props: {
            label: $localize`Header Name:`,
          },
        }, {
          key: 'field',
          type: 'string',
          props: {
            label: $localize`Field:`,
          },
        }, {
          key: 'type',
          type: 'select',
          defaultValue: '',
          props: {
            label: $localize`Type:`,
            options: [
              { value: '' },
              { value: 'text', label: $localize`Text` },
              { value: 'number', label: $localize`Number` },
              { value: 'boolean', label: $localize`Boolean` },
              { value: 'date', label: $localize`Date` },
              { value: 'dateString', label: $localize`Date (String)` },
              { value: 'dateTime', label: $localize`Date Time` },
              { value: 'dateTimeString', label: $localize`Date Time (String)` },
              { value: 'url', label: $localize`URL` },
              { value: 'tag', label: $localize`Tag` },
              { value: 'tags', label: $localize`Tag List` },
              { value: 'sources', label: $localize`Sources` },
              { value: 'image', label: $localize`Image` },
              { value: 'lens', label: $localize`Lens` },
              { value: 'markdown', label: $localize`Markdown` },
              { value: 'embed', label: $localize`Embed` },
            ],
          }
        }]
      },
    }]
  },
  schema: {
    optionalProperties: {
      columnDefs: {
        elements: {
          optionalProperties: {
            headerName: { type: 'string' },
            field: { type: 'string' },
            type: { type: 'string' },
            width: { type: 'uint32' },
            minWidth: { type: 'uint32' },
            flex: { type: 'uint32' },
          }
        }
      }
    }
  },
  defaults: {
    submitText: true,
    noFloatingSidebar: true,
    columnDefs: [
      { headerName: $localize`Thumbnail`, field: 'plugins.plugin/thumbnail.url', type: 'image' },
      { headerName: $localize`Title`, field: 'title', type: 'text', flex: 2 },
      { headerName: $localize`Published`, field: 'published', type: 'dateTime' },
      { headerName: $localize`Tags`, field: 'tags', type: 'tags', flex: 1 },
    ],
  }
};
 
 
export const gridMod: Mod = {
  template: [
    gridTemplate,
  ]
};