<commit_before>import React from 'react';
import t from 'tcomb-form';

import VirtualKeyboardFactory from 'views/components/Editor/fields/virtualKeyboard';

import WysiwygFactory from 'views/components/Editor/fields/wysiwyg';
import SelectSuggestFactory from 'views/components/Editor/fields/selectSuggest';
import SelectFactory from 'views/components/Editor/fields/select';
import MediaFactory from 'views/components/Editor/fields/media';

const i18nExt = {
  add: '+ Add',
  down: '▼',
  remove: 'X',
  up: '▲',
  optional: '(optional)'
}

const configExt = {
  config: {
    // for each of lg md sm xs you can specify the columns width
    horizontal: {
      md: [3, 9],
      sm: [6, 6]
    }
  }
}

const DefinitionsLayout = function (locals) {
  return (

          {locals.inputs.language}
          {locals.inputs.translation}

  );
};

t.String.getValidationErrorMessage = (value, path, context) => {
  if (!value) {
    return 'Value in field ' + context.options.label + ' cannot be empty.';
  }
};

const options = {
  FVWord: {
    order: ['dc:title', 'fv-word:part_of_speech', 'fv-word:pronunciation', 'fv:definitions', 'fv:literal_translation', 'fv-word:related_phrases', 'fv-word:categories', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fv:cultural_note', 'fv:reference', 'fv:source', 'fv:available_in_childrens_archive'],
    fields: {
      'dc:title': {
        label: 'Word',
        factory: VirtualKeyboardFactory
       },
      'fv:definitions': {
        label: 'Definitions',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              factory: VirtualKeyboardFactory
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word actually means.
      },
      'fv:literal_translation': {
        label: 'Literal Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              factory: VirtualKeyboardFactory
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word translates to regradless of context.
      },
      'fv-word:part_of_speech' : {
        label: 'Part of Speech',
        factory: SelectFactory,
        attrs: {
          directory: 'parts_of_speech'
        }
      },
      'fv-word:pronunciation' : {
        label: 'Pronunciation',
        factory: VirtualKeyboardFactory
      },
      'fv-word:related_phrases' : {
        label: 'Related Phrases',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVPhrase'
        }
      },
      'fv-word:categories' : {
        label: 'Categories',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVCategory',
          attrs: {
            page_provider: {
              name: 'category_suggestion',
              folder: 'Categories'
            }
          }
        }
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fv:cultural_note' : {
        label: 'Cultural Note',
        item: {
          factory: VirtualKeyboardFactory,
          type: 'FVVideo'
        }
      },
      'fv:reference': {
        label: 'Reference',
        help: Origin of record (person, book, etc).,
        factory: VirtualKeyboardFactory
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:available_in_childrens_archive': {
        label: 'Available in Children\'s Archive'
      }
    },
    i18n: i18nExt
  },
  FVPhrase: {
    order: ['dc:title', 'fv:definitions', 'fv-phrase:phrase_books', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fv:cultural_note', 'fv:reference', 'fv:source', 'fv:available_in_childrens_archive'],
    fields: {
      'dc:title': {
        label: 'Phrase'
       },
      'fv:definitions': {
        label: 'Definitions',
        item: {
          fields: {
            translation: {
              label: 'Translation'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word actually means.
      },
      'fv-phrase:phrase_books' : {
        label: 'Phrase Books',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVCategory',
          attrs: {
            page_provider: {
              name: 'phrasebook_suggestion',
              folder: 'Phrase Books'
            }
          }
        }
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fv:cultural_note' : {
        label: 'Cultural Notes'
      },
      'fv:reference': {
        label: 'Reference',
        help: Origin of record (person, book, etc).
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:available_in_childrens_archive': {
        label: 'Available in Children\'s Archive'
      }
    },
    i18n: i18nExt
  },
  FVBook: {
    order: ['dc:title', 'fvbook:title_literal_translation', 'fvbook:introduction', 'fvbook:introduction_literal_translation', 'fvbook:type', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fvbook:author', 'fv:cultural_note', 'fv:source', 'fv:available_in_childrens_archive'],
    fields: {
      'dc:title': {
        label: 'Book Name',
        help: The name of the song or story
       },
      'fvbook:title_literal_translation': {
        label: 'Title Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word translates to regradless of context.
      },
      'fvbook:introduction': {
        label: 'Book Introduction',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter book introduction here'
        }
      },
      'fvbook:introduction_literal_translation': {
        label: 'Introduction Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              type: 'textarea'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word translates to regradless of context.
      },
      'fvbook:type': {
        label: 'Type',
        factory: SelectFactory,
        attrs: {
          directory: 'fv_book_type'
        }
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fvbook:author': {
        label: 'Author',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:cultural_note' : {
        label: 'Cultural Notes'
      },
      'fv:available_in_childrens_archive': {
        label: 'Available in Children\'s Archive'
      }
    },
    i18n: i18nExt
  },
  FVBookEntry: {
    order: ['dc:title', 'fv:literal_translation', 'fvbookentry:dominant_language_text', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fv:cultural_note', 'fv:source', 'fvbookentry:sort_map'],
    fields: {
      'dc:title': {
        label: 'Book Entry Name'
       },
      'fv:literal_translation': {
        label: 'Literal Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              type: 'textarea'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the book entry translates to regradless of context.
      },
      'fvbookentry:dominant_language_text': {
        label: 'Dominant Language Text',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              type: 'textarea'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the book entry translates to regradless of context.
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fvbookentry:sort_map': {
        label: 'Order'
      },
      'fv:cultural_note' : {
        label: 'Cultural Notes'
      }
    },
    i18n: i18nExt
  },
  FVGallery: {
    order: ['dc:title', 'dc:description', 'fv:related_pictures'],
    fields: {
      'dc:title': {
        label: 'Gallery Name',
        help: The name of the gallery
       },

      'dc:description': {
        label: 'Gallery Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter gallery description here'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      }
    },
    i18n: i18nExt
  },

  FVCategory: {
    order: ['dc:title', 'dc:description', 'fvcategory:parent_category', 'fvcategory:image'],
    fields: {
      'dc:title': {
        label: 'Category Name',
        help: The name of the category
       },

      'dc:description': {
        label: 'Category Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter category description here'
        }
      },
      'fvcategory:parent_category': {
          label: 'Parent Category Name',
          help: The name of the parent category,
          factory: SelectSuggestFactory,
          type: 'FVCategory',
          attrs: {
            page_provider: {
              name: 'category_suggestion',
              folder: 'Categories'
            },
            disableCreateNewButton: true
          }
       },
      'fvcategory:image' : {
        label: 'Category Image',
        factory: MediaFactory,
        type: 'FVPicture'
      }
    },
    i18n: i18nExt
  },

  FVPhraseBook: {
    order: ['dc:title', 'dc:description'],
    fields: {
      'dc:title': {
        label: 'Phrase Book Name',
        help: The name of the phrase book
       },

      'dc:description': {
        label: 'Phrase Book Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter phrase book description here'
        }
      }
    },
    i18n: i18nExt
  },

  FVContributor: {
    order: ['dc:title', 'dc:description'],
    fields: {
      'dc:title': {
        label: 'Contributor Name',
        help: The name of the contributor
       },

      'dc:description': {
        label: 'Contributor Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter contributor description here'
        }
      }
    },
    i18n: i18nExt
  },

  FVPortal: {
    fields: {
      'fv-portal:greeting': {
        label: 'Portal Greeting'
      },
      'fv-portal:about': {
        label: 'Portal Introduction',
        type: 'textarea',
        factory: WysiwygFactory,
        attrs: {
          placeholder: 'Enter portal description here'
        }
      },
      'fv-portal:featured_audio' : {
        label: 'Featured Audio',
        factory: MediaFactory,
        type: 'FVAudio'
      },
      'fv-portal:featured_words' : {
        label: 'Featured Words',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVWord',
          attrs: {
            disableCreateNewButton: true
          }
        }
      },
      'fv-portal:background_top_image' : {
        label: 'Background Image',
        factory: MediaFactory,
        type: 'FVPicture'
      },
      'fv-portal:logo' : {
        label: 'Logo',
        factory: MediaFactory,
        type: 'FVPicture'
      }
    },
    i18n: i18nExt
  },
  FVDialect: {
    fields: {
      'dc:title': {
        label: 'Dialect Name',
        type: 'text'
      },
      'dc:description': {
        label: 'About Dialect',
        type: 'textarea',
        factory: WysiwygFactory
      },
      'fvdialect:country': {
        label: 'Country',
        factory: SelectFactory,
        attrs: {
          fancy: false,
          directory: 'fv_countries'
        }
      },
      'fvdialect:dominant_language': {
        label: 'Dominant Language',
        factory: SelectFactory,
        attrs: {
          fancy: false,
          directory: 'fv_language'
        }
      },
      'fvdialect:region': {
        label: 'Region',
        type: 'text'
      },
      'fvdialect:contact_information': {
        label: 'Contact Information',
        type: 'textarea',
        factory: WysiwygFactory
      }
    },
    i18n: i18nExt
  }
};

export default options;<commit_msg>fixed typo<commit_after>import React from 'react';
import t from 'tcomb-form';

import VirtualKeyboardFactory from 'views/components/Editor/fields/virtualKeyboard';

import WysiwygFactory from 'views/components/Editor/fields/wysiwyg';
import SelectSuggestFactory from 'views/components/Editor/fields/selectSuggest';
import SelectFactory from 'views/components/Editor/fields/select';
import MediaFactory from 'views/components/Editor/fields/media';

const i18nExt = {
  add: '+ Add',
  down: '▼',
  remove: 'X',
  up: '▲',
  optional: '(optional)'
}

const configExt = {
  config: {
    // for each of lg md sm xs you can specify the columns width
    horizontal: {
      md: [3, 9],
      sm: [6, 6]
    }
  }
}

const DefinitionsLayout = function (locals) {
  return (

          {locals.inputs.language}
          {locals.inputs.translation}

  );
};

t.String.getValidationErrorMessage = (value, path, context) => {
  if (!value) {
    return 'Value in field ' + context.options.label + ' cannot be empty.';
  }
};

const options = {
  FVWord: {
    order: ['dc:title', 'fv-word:part_of_speech', 'fv-word:pronunciation', 'fv:definitions', 'fv:literal_translation', 'fv-word:related_phrases', 'fv-word:categories', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fv:cultural_note', 'fv:reference', 'fv:source', 'fv:available_in_childrens_archive'],
    fields: {
      'dc:title': {
        label: 'Word',
        factory: VirtualKeyboardFactory
       },
      'fv:definitions': {
        label: 'Definitions',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              factory: VirtualKeyboardFactory
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word actually means.
      },
      'fv:literal_translation': {
        label: 'Literal Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              factory: VirtualKeyboardFactory
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word translates to regardless of context.
      },
      'fv-word:part_of_speech' : {
        label: 'Part of Speech',
        factory: SelectFactory,
        attrs: {
          directory: 'parts_of_speech'
        }
      },
      'fv-word:pronunciation' : {
        label: 'Pronunciation',
        factory: VirtualKeyboardFactory
      },
      'fv-word:related_phrases' : {
        label: 'Related Phrases',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVPhrase'
        }
      },
      'fv-word:categories' : {
        label: 'Categories',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVCategory',
          attrs: {
            page_provider: {
              name: 'category_suggestion',
              folder: 'Categories'
            }
          }
        }
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fv:cultural_note' : {
        label: 'Cultural Note',
        item: {
          factory: VirtualKeyboardFactory,
          type: 'FVVideo'
        }
      },
      'fv:reference': {
        label: 'Reference',
        help: Origin of record (person, book, etc).,
        factory: VirtualKeyboardFactory
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:available_in_childrens_archive': {
        label: 'Available in Children\'s Archive'
      }
    },
    i18n: i18nExt
  },
  FVPhrase: {
    order: ['dc:title', 'fv:definitions', 'fv-phrase:phrase_books', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fv:cultural_note', 'fv:reference', 'fv:source', 'fv:available_in_childrens_archive'],
    fields: {
      'dc:title': {
        label: 'Phrase'
       },
      'fv:definitions': {
        label: 'Definitions',
        item: {
          fields: {
            translation: {
              label: 'Translation'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word actually means.
      },
      'fv-phrase:phrase_books' : {
        label: 'Phrase Books',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVCategory',
          attrs: {
            page_provider: {
              name: 'phrasebook_suggestion',
              folder: 'Phrase Books'
            }
          }
        }
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fv:cultural_note' : {
        label: 'Cultural Notes'
      },
      'fv:reference': {
        label: 'Reference',
        help: Origin of record (person, book, etc).
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:available_in_childrens_archive': {
        label: 'Available in Children\'s Archive'
      }
    },
    i18n: i18nExt
  },
  FVBook: {
    order: ['dc:title', 'fvbook:title_literal_translation', 'fvbook:introduction', 'fvbook:introduction_literal_translation', 'fvbook:type', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fvbook:author', 'fv:cultural_note', 'fv:source', 'fv:available_in_childrens_archive'],
    fields: {
      'dc:title': {
        label: 'Book Name',
        help: The name of the song or story
       },
      'fvbook:title_literal_translation': {
        label: 'Title Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word translates to regardless of context.
      },
      'fvbook:introduction': {
        label: 'Book Introduction',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter book introduction here'
        }
      },
      'fvbook:introduction_literal_translation': {
        label: 'Introduction Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              type: 'textarea'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the word translates to regardless of context.
      },
      'fvbook:type': {
        label: 'Type',
        factory: SelectFactory,
        attrs: {
          directory: 'fv_book_type'
        }
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fvbook:author': {
        label: 'Author',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fv:cultural_note' : {
        label: 'Cultural Notes'
      },
      'fv:available_in_childrens_archive': {
        label: 'Available in Children\'s Archive'
      }
    },
    i18n: i18nExt
  },
  FVBookEntry: {
    order: ['dc:title', 'fv:literal_translation', 'fvbookentry:dominant_language_text', 'fv:related_audio', 'fv:related_pictures', 'fv:related_videos', 'fv:cultural_note', 'fv:source', 'fvbookentry:sort_map'],
    fields: {
      'dc:title': {
        label: 'Book Entry Name'
       },
      'fv:literal_translation': {
        label: 'Literal Translation',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              type: 'textarea'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the book entry translates to regardless of context.
      },
      'fvbookentry:dominant_language_text': {
        label: 'Dominant Language Text',
        item: {
          fields: {
            translation: {
              label: 'Translation',
              type: 'textarea'
            },
            language: {
              label: 'Language',
              factory: SelectFactory,
              attrs: {
                defaultValue: 'english',
                directory: 'fv_language'
              }
            }
          },
          template: DefinitionsLayout
        },
        help: Describe what the book entry translates to regardless of context.
      },
      'fv:related_audio' : {
        label: 'Related Audio',
        item: {
          factory: MediaFactory,
          type: 'FVAudio'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      },
      'fv:related_videos' : {
        label: 'Related Videos',
        item: {
          factory: MediaFactory,
          type: 'FVVideo'
        }
      },
      'fv:source': {
        label: 'Source',
        help: Contributor(s) who helped create this record.,
        item: {
          factory: SelectSuggestFactory,
          type: 'FVContributor'
        }
      },
      'fvbookentry:sort_map': {
        label: 'Order'
      },
      'fv:cultural_note' : {
        label: 'Cultural Notes'
      }
    },
    i18n: i18nExt
  },
  FVGallery: {
    order: ['dc:title', 'dc:description', 'fv:related_pictures'],
    fields: {
      'dc:title': {
        label: 'Gallery Name',
        help: The name of the gallery
       },

      'dc:description': {
        label: 'Gallery Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter gallery description here'
        }
      },
      'fv:related_pictures' : {
        label: 'Related Pictures',
        item: {
          factory: MediaFactory,
          type: 'FVPicture'
        }
      }
    },
    i18n: i18nExt
  },

  FVCategory: {
    order: ['dc:title', 'dc:description', 'fvcategory:parent_category', 'fvcategory:image'],
    fields: {
      'dc:title': {
        label: 'Category Name',
        help: The name of the category
       },

      'dc:description': {
        label: 'Category Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter category description here'
        }
      },
      'fvcategory:parent_category': {
          label: 'Parent Category Name',
          help: The name of the parent category,
          factory: SelectSuggestFactory,
          type: 'FVCategory',
          attrs: {
            page_provider: {
              name: 'category_suggestion',
              folder: 'Categories'
            },
            disableCreateNewButton: true
          }
       },
      'fvcategory:image' : {
        label: 'Category Image',
        factory: MediaFactory,
        type: 'FVPicture'
      }
    },
    i18n: i18nExt
  },

  FVPhraseBook: {
    order: ['dc:title', 'dc:description'],
    fields: {
      'dc:title': {
        label: 'Phrase Book Name',
        help: The name of the phrase book
       },

      'dc:description': {
        label: 'Phrase Book Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter phrase book description here'
        }
      }
    },
    i18n: i18nExt
  },

  FVContributor: {
    order: ['dc:title', 'dc:description'],
    fields: {
      'dc:title': {
        label: 'Contributor Name',
        help: The name of the contributor
       },

      'dc:description': {
        label: 'Contributor Description',
        type: 'textarea',
        attrs: {
          placeholder: 'Enter contributor description here'
        }
      }
    },
    i18n: i18nExt
  },

  FVPortal: {
    fields: {
      'fv-portal:greeting': {
        label: 'Portal Greeting'
      },
      'fv-portal:about': {
        label: 'Portal Introduction',
        type: 'textarea',
        factory: WysiwygFactory,
        attrs: {
          placeholder: 'Enter portal description here'
        }
      },
      'fv-portal:featured_audio' : {
        label: 'Featured Audio',
        factory: MediaFactory,
        type: 'FVAudio'
      },
      'fv-portal:featured_words' : {
        label: 'Featured Words',
        item: {
          factory: SelectSuggestFactory,
          type: 'FVWord',
          attrs: {
            disableCreateNewButton: true
          }
        }
      },
      'fv-portal:background_top_image' : {
        label: 'Background Image',
        factory: MediaFactory,
        type: 'FVPicture'
      },
      'fv-portal:logo' : {
        label: 'Logo',
        factory: MediaFactory,
        type: 'FVPicture'
      }
    },
    i18n: i18nExt
  },
  FVDialect: {
    fields: {
      'dc:title': {
        label: 'Dialect Name',
        type: 'text'
      },
      'dc:description': {
        label: 'About Dialect',
        type: 'textarea',
        factory: WysiwygFactory
      },
      'fvdialect:country': {
        label: 'Country',
        factory: SelectFactory,
        attrs: {
          fancy: false,
          directory: 'fv_countries'
        }
      },
      'fvdialect:dominant_language': {
        label: 'Dominant Language',
        factory: SelectFactory,
        attrs: {
          fancy: false,
          directory: 'fv_language'
        }
      },
      'fvdialect:region': {
        label: 'Region',
        type: 'text'
      },
      'fvdialect:contact_information': {
        label: 'Contact Information',
        type: 'textarea',
        factory: WysiwygFactory
      }
    },
    i18n: i18nExt
  }
};

export default options;<|endoftext|>


<commit_before>// vars
var data = {},
    unicoreData = [],
    order = [],
    lca = 0,
    pans = [],
    cores = [],
    unicores = [];
    unicorePresent = false;

// Add an event handler to the worker
self.addEventListener('message', function (e) {
    var data = e.data;
    switch (data.cmd) {
    case 'log':
        sendToHost("log", data.msg);
        break;
    case 'loadData':
        loadData(data.msg.bioproject_id, data.msg.name);
        break;
    case 'removeData':
        removeData(data.msg.bioproject_id, data.msg.order, data.msg.start);
        break;
    case 'clearAllData':
        clearAllData();
        break;
    case 'recalculatePanCore':
        recalculatePanCore(data.msg.order, data.msg.start, data.msg.stop);
        break;
    case 'getUniqueSequences':
        getUniqueSequences(data.msg.type);
        break;
    case 'autoSort':
        autoSort(data.msg.type);
        break;
    default:
        sendToHost("error", data.msg);
    }
}, false);

// Sends a response type and message to the host
function sendToHost(type, message) {
    self.postMessage({'type': type, 'msg': message});
}

// Loads peptides, based on bioproject_id
function loadData(bioproject_id, name) {
    getJSON("/pancore/sequences/" + bioproject_id + ".json", function (json_data) {
        addData(bioproject_id, name, json_data);
    });
}

// Adds new dataset to the data array
function addData(bioproject_id, name, set) {
    var core,
        pan,
        unicore,
        temp;
    // Store data for later use
    data[bioproject_id] = {};
    data[bioproject_id].bioproject_id = bioproject_id;
    data[bioproject_id].name = name;
    data[bioproject_id].peptide_list = set;
    data[bioproject_id].peptides = set.length;
    order.push(bioproject_id);

    // Calculate pan and core
    core = cores.length === 0 ? set : intersection(cores[cores.length - 1], set);
    pan = pans.length === 0 ? set : union(pans[pans.length - 1], set);
    pans.push(pan);
    cores.push(core);
    if (unicorePresent) {
        unicore = intersection(unicores[unicores.length - 1], set);
        unicores.push(unicore);
    }

    // Return the results to the host
    temp = {};
    temp.bioproject_id = bioproject_id;
    temp.pan = pan.length;
    temp.core = core.length;
    temp.peptides = set.length;
    if (unicorePresent) {
        temp.unicore = unicore.length;
    }
    sendToHost("addData", temp);
}

// Removes a genomes from the data
function removeData(bioproject_id, newOrder, start) {
    var l = pans.length;
    delete data[bioproject_id];
    pans.splice(l - 1, 1);
    cores.splice(l - 1, 1);
    unicores.splice(l - 1, 1);
    unicorePresent = false;
    unicores = [];
    recalculatePanCore(newOrder, start, l - 2);
    getUniqueSequences("uniprot");
}

// Recalculates the pan and core data based on a
// given order, from start till stop
function recalculatePanCore(newOrder, start, stop) {
    var i = 0,
        set,
        temp,
        response = [];
    if (start === 0) {
        unicorePresent = false;
        unicores = [];
        getUniqueSequences("uniprot");
    }
    order = newOrder;
    for (i = start; i <= stop; i++) {
        set = data[order[i]].peptide_list;
        if (i === 0) {
            cores[i] = set;
            pans[i] = set;
        } else {
            cores[i] = intersection(cores[i - 1], set);
            pans[i] = union(pans[i - 1], set);
            if (unicorePresent) {
                unicores[i] = intersection(unicores[i - 1], set);
            }
        }
    }
    for (i = 0; i < order.length; i++) {
        temp = {};
        temp.bioproject_id = order[i];
        temp.pan = pans[i].length;
        temp.core = cores[i].length;
        temp.peptides = data[order[i]].peptides;
        if (unicorePresent) {
            temp.unicore = unicores[i].length;
        }
        response.push(temp);
    }
    sendToHost("setVisData", response);
}

function autoSort(type) {
    var i,
        sortFunction,
        tempPan,
        tempCore,
        optId,
        optVal,
        temp,
        easySort = true,
        sortableArray = [],
        tempOrder = [],
        newOrder = [];
    // Set up sort function based on type
    switch (type) {
        case 'name':
            sortFunction = function (a, b) {
                if (a.name < b.name) {
                    return -1;
                }
                if (b.name < a.name) {
                    return 1;
                }
                return 0;
            };
            break;
        case 'size':
            sortFunction = function (a, b) {
                return a.size < b.size;
            };
            break;
        default:
            easySort = false;
    }
    // Prepare the array to sort
    for (i in data) {
        sortableArray.push({bioproject_id : data[i].bioproject_id, name : data[i].name, size : data[i].peptides});
    }
    // Do the actual sorting
    if (easySort) {
        sortableArray.sort(sortFunction);
    } else {
        tempPan = data[order[0]].peptide_list;
        tempCore = data[order[0]].peptide_list;
        for (i = 0; i < sortableArray.length; i++) {
            if (sortableArray[i].bioproject_id === order[0]) {
                tempOrder.push(sortableArray[i]);
                delete sortableArray[i];
                break;
            }
        }
        while (tempOrder.length < sortableArray.length) {
            optId = -1;
            optVal = 0;
            for (i = 0; i < sortableArray.length; i++) {
                if (sortableArray[i] !== undefined) {
                    if (type === "minpan") {
                        temp = union(tempPan, data[sortableArray[i].bioproject_id].peptide_list);
                        if (optId === -1 || temp.length < optVal) {
                            optId = i;
                            optVal = temp.length;
                        }
                    } else if (type === "maxcore") {
                        temp = intersection(tempCore, data[sortableArray[i].bioproject_id].peptide_list);
                        if (optId === -1 || temp.length > optVal) {
                            optId = i;
                            optVal = temp.length;
                        }
                    } else if (type === "optimal") {
                        temp = union(tempPan, data[sortableArray[i].bioproject_id].peptide_list).length - intersection(tempCore, data[sortableArray[i].bioproject_id].peptide_list).length;
                        if (optId === -1 || temp < optVal) {
                            optId = i;
                            optVal = temp;
                        }
                    }
                }
            }
            if (type === "minpan") {
                tempPan = union(tempPan, data[sortableArray[optId].bioproject_id].peptide_list);
            } else if (type === "maxcore") {
                tempCore = intersection(tempCore, data[sortableArray[optId].bioproject_id].peptide_list);
            } else if (type === "optimal") {
                tempPan = union(tempPan, data[sortableArray[optId].bioproject_id].peptide_list);
                tempCore = intersection(tempCore, data[sortableArray[optId].bioproject_id].peptide_list);
            }
            tempOrder.push(sortableArray[optId]);
            delete sortableArray[optId];
        }
        sortableArray = tempOrder;
    }
    // Prepare to return the result
    for (i = 0; i < sortableArray.length; i++) {
        newOrder.push(sortableArray[i].bioproject_id);
    }
    recalculatePanCore(newOrder, 0, newOrder.length - 1);
}

// Retrieves the unique sequences
function getUniqueSequences(type) {
    var r = data[order[0]].peptide_list;
    getJSONByPost("/pancore/unique_sequences/", "type=" + type + "&bioprojects=" + order + "&sequences=[" + r + "]", function (d) {calculateUnicore(d, type); });
}

// Calculates the unique peptides data
function calculateUnicore(ud, type) {
    var u,
        i,
        set;
    unicorePresent = true;
    if (type === "uniprot") {
        unicoreData = ud;
        unicores[0] = unicoreData;
        u = unicores;
    } /*    else {
            unicore2Data = ud;
            unicores2[0] = unicore2Data;
            u = unicores2;
        }*/
    for (i = 1; i < order.length; i++) {
        set = data[order[i]];
        u[i] = intersection(u[i - 1], set);
    }
    recalculatePanCore(order, 1, -1);
}

// Resets the data vars
function clearAllData() {
    data = {};
    unicoreData = [];
    unicore2Data = [];
    order = [];
    lca = 0;
    pans = [];
    cores = [];
    unicores = [];
}

// Provide an error function with the same signature as in the host
function error(error, message) {
    sendToHost("error", {"error" : error, "msg" : message});
}

// Wrapper around xhr json request
function getJSON(url, callback) {
    var req = new XMLHttpRequest();
    req.open('GET', url, true);
    req.onreadystatechange = function () {
        if (req.readyState === 4) {
            if (req.status === 200) {
                var data = JSON.parse(req.responseText);
                callback(data);
            } else {
                error("request error for " + url, "It seems like something went wrong while we loaded the data");
            }
        }
    };
    req.send(null);
}

// Wrapper around xhr json request
function getJSONByPost(url, data, callback) {
    var req = new XMLHttpRequest();
    req.open('POST', url, true);
    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    req.onreadystatechange = function () {
        if (req.readyState === 4) {
            if (req.status === 200) {
                var data = JSON.parse(req.responseText);
                callback(data);
            } else {
                error("request error for " + url, "It seems like something went wrong while we loaded the data");
            }
        }
    };
    req.send(data);
}

// union and intersection for sorted arrays
function union(a, b) {
    var r = [],
        i = 0,
        j = 0;
    while (i < a.length && j < b.length) {
        if (a[i] < b[j]) {
            r.push(a[i]);
            i++;
        } else if (a[i] > b[j]) {
            r.push(b[j]);
            j++;
        } else {
            r.push(a[i]);
            i++;
            j++;
        }
    }
    while (i < a.length) {
        r.push(a[i]);
        i++;
    }
    while (j < b.length) {
        r.push(b[j]);
        j++;
    }
    return r;
}
function intersection(a, b) {
    var r = [],
        i = 0,
        j = 0;
    while (i < a.length && j < b.length) {
        if (a[i] < b[j]) {
            i++;
        } else if (a[i] > b[j]) {
            j++;
        } else {
            r.push(a[i]);
            i++;
            j++;
        }
    }
    return r;
}<commit_msg>fix bug with remove all<commit_after>// vars
var data = {},
    unicoreData = [],
    order = [],
    lca = 0,
    pans = [],
    cores = [],
    unicores = [];
    unicorePresent = false;

// Add an event handler to the worker
self.addEventListener('message', function (e) {
    var data = e.data;
    switch (data.cmd) {
    case 'log':
        sendToHost("log", data.msg);
        break;
    case 'loadData':
        loadData(data.msg.bioproject_id, data.msg.name);
        break;
    case 'removeData':
        removeData(data.msg.bioproject_id, data.msg.order, data.msg.start);
        break;
    case 'clearAllData':
        clearAllData();
        break;
    case 'recalculatePanCore':
        recalculatePanCore(data.msg.order, data.msg.start, data.msg.stop);
        break;
    case 'getUniqueSequences':
        getUniqueSequences(data.msg.type);
        break;
    case 'autoSort':
        autoSort(data.msg.type);
        break;
    default:
        sendToHost("error", data.msg);
    }
}, false);

// Sends a response type and message to the host
function sendToHost(type, message) {
    self.postMessage({'type': type, 'msg': message});
}

// Loads peptides, based on bioproject_id
function loadData(bioproject_id, name) {
    getJSON("/pancore/sequences/" + bioproject_id + ".json", function (json_data) {
        addData(bioproject_id, name, json_data);
    });
}

// Adds new dataset to the data array
function addData(bioproject_id, name, set) {
    var core,
        pan,
        unicore,
        temp;
    // Store data for later use
    data[bioproject_id] = {};
    data[bioproject_id].bioproject_id = bioproject_id;
    data[bioproject_id].name = name;
    data[bioproject_id].peptide_list = set;
    data[bioproject_id].peptides = set.length;
    order.push(bioproject_id);

    // Calculate pan and core
    core = cores.length === 0 ? set : intersection(cores[cores.length - 1], set);
    pan = pans.length === 0 ? set : union(pans[pans.length - 1], set);
    pans.push(pan);
    cores.push(core);
    if (unicorePresent) {
        unicore = intersection(unicores[unicores.length - 1], set);
        unicores.push(unicore);
    }

    // Return the results to the host
    temp = {};
    temp.bioproject_id = bioproject_id;
    temp.pan = pan.length;
    temp.core = core.length;
    temp.peptides = set.length;
    if (unicorePresent) {
        temp.unicore = unicore.length;
    }
    sendToHost("addData", temp);
}

// Removes a genomes from the data
function removeData(bioproject_id, newOrder, start) {
    var l = pans.length;
    delete data[bioproject_id];
    pans.splice(l - 1, 1);
    cores.splice(l - 1, 1);
    unicores.splice(l - 1, 1);
    unicorePresent = false;
    unicores = [];
    recalculatePanCore(newOrder, start, l - 2);
    getUniqueSequences("uniprot");
}

// Recalculates the pan and core data based on a
// given order, from start till stop
function recalculatePanCore(newOrder, start, stop) {
    var i = 0,
        set,
        temp,
        response = [];
    if (start === 0) {
        unicorePresent = false;
        unicores = [];
        getUniqueSequences("uniprot");
    }
    order = newOrder;
    for (i = start; i <= stop; i++) {
        set = data[order[i]].peptide_list;
        if (i === 0) {
            cores[i] = set;
            pans[i] = set;
        } else {
            cores[i] = intersection(cores[i - 1], set);
            pans[i] = union(pans[i - 1], set);
            if (unicorePresent) {
                unicores[i] = intersection(unicores[i - 1], set);
            }
        }
    }
    for (i = 0; i < order.length; i++) {
        temp = {};
        temp.bioproject_id = order[i];
        temp.pan = pans[i].length;
        temp.core = cores[i].length;
        temp.peptides = data[order[i]].peptides;
        if (unicorePresent) {
            temp.unicore = unicores[i].length;
        }
        response.push(temp);
    }
    sendToHost("setVisData", response);
}

function autoSort(type) {
    var i,
        sortFunction,
        tempPan,
        tempCore,
        optId,
        optVal,
        temp,
        easySort = true,
        sortableArray = [],
        tempOrder = [],
        newOrder = [];
    // Set up sort function based on type
    switch (type) {
        case 'name':
            sortFunction = function (a, b) {
                if (a.name < b.name) {
                    return -1;
                }
                if (b.name < a.name) {
                    return 1;
                }
                return 0;
            };
            break;
        case 'size':
            sortFunction = function (a, b) {
                return a.size < b.size;
            };
            break;
        default:
            easySort = false;
    }
    // Prepare the array to sort
    for (i in data) {
        sortableArray.push({bioproject_id : data[i].bioproject_id, name : data[i].name, size : data[i].peptides});
    }
    // Do the actual sorting
    if (easySort) {
        sortableArray.sort(sortFunction);
    } else {
        tempPan = data[order[0]].peptide_list;
        tempCore = data[order[0]].peptide_list;
        for (i = 0; i < sortableArray.length; i++) {
            if (sortableArray[i].bioproject_id === order[0]) {
                tempOrder.push(sortableArray[i]);
                delete sortableArray[i];
                break;
            }
        }
        while (tempOrder.length < sortableArray.length) {
            optId = -1;
            optVal = 0;
            for (i = 0; i < sortableArray.length; i++) {
                if (sortableArray[i] !== undefined) {
                    if (type === "minpan") {
                        temp = union(tempPan, data[sortableArray[i].bioproject_id].peptide_list);
                        if (optId === -1 || temp.length < optVal) {
                            optId = i;
                            optVal = temp.length;
                        }
                    } else if (type === "maxcore") {
                        temp = intersection(tempCore, data[sortableArray[i].bioproject_id].peptide_list);
                        if (optId === -1 || temp.length > optVal) {
                            optId = i;
                            optVal = temp.length;
                        }
                    } else if (type === "optimal") {
                        temp = union(tempPan, data[sortableArray[i].bioproject_id].peptide_list).length - intersection(tempCore, data[sortableArray[i].bioproject_id].peptide_list).length;
                        if (optId === -1 || temp < optVal) {
                            optId = i;
                            optVal = temp;
                        }
                    }
                }
            }
            if (type === "minpan") {
                tempPan = union(tempPan, data[sortableArray[optId].bioproject_id].peptide_list);
            } else if (type === "maxcore") {
                tempCore = intersection(tempCore, data[sortableArray[optId].bioproject_id].peptide_list);
            } else if (type === "optimal") {
                tempPan = union(tempPan, data[sortableArray[optId].bioproject_id].peptide_list);
                tempCore = intersection(tempCore, data[sortableArray[optId].bioproject_id].peptide_list);
            }
            tempOrder.push(sortableArray[optId]);
            delete sortableArray[optId];
        }
        sortableArray = tempOrder;
    }
    // Prepare to return the result
    for (i = 0; i < sortableArray.length; i++) {
        newOrder.push(sortableArray[i].bioproject_id);
    }
    recalculatePanCore(newOrder, 0, newOrder.length - 1);
}

// Retrieves the unique sequences
function getUniqueSequences(type) {
    var r = data[order[0]].peptide_list;
    getJSONByPost("/pancore/unique_sequences/", "type=" + type + "&bioprojects=" + order + "&sequences=[" + r + "]", function (d) {calculateUnicore(d, type); });
}

// Calculates the unique peptides data
function calculateUnicore(ud, type) {
    var u,
        i,
        set;
    unicorePresent = true;
    if (type === "uniprot") {
        unicoreData = ud;
        unicores[0] = unicoreData;
        u = unicores;
    } /*    else {
            unicore2Data = ud;
            unicores2[0] = unicore2Data;
            u = unicores2;
        }*/
    for (i = 1; i < order.length; i++) {
        set = data[order[i]];
        u[i] = intersection(u[i - 1], set);
    }
    recalculatePanCore(order, 1, -1);
}

// Resets the data vars
function clearAllData() {
    unicorePresent = false;
    data = {};
    unicoreData = [];
    unicore2Data = [];
    order = [];
    lca = 0;
    pans = [];
    cores = [];
    unicores = [];
}

// Provide an error function with the same signature as in the host
function error(error, message) {
    sendToHost("error", {"error" : error, "msg" : message});
}

// Wrapper around xhr json request
function getJSON(url, callback) {
    var req = new XMLHttpRequest();
    req.open('GET', url, true);
    req.onreadystatechange = function () {
        if (req.readyState === 4) {
            if (req.status === 200) {
                var data = JSON.parse(req.responseText);
                callback(data);
            } else {
                error("request error for " + url, "It seems like something went wrong while we loaded the data");
            }
        }
    };
    req.send(null);
}

// Wrapper around xhr json request
function getJSONByPost(url, data, callback) {
    var req = new XMLHttpRequest();
    req.open('POST', url, true);
    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    req.onreadystatechange = function () {
        if (req.readyState === 4) {
            if (req.status === 200) {
                var data = JSON.parse(req.responseText);
                callback(data);
            } else {
                error("request error for " + url, "It seems like something went wrong while we loaded the data");
            }
        }
    };
    req.send(data);
}

// union and intersection for sorted arrays
function union(a, b) {
    var r = [],
        i = 0,
        j = 0;
    while (i < a.length && j < b.length) {
        if (a[i] < b[j]) {
            r.push(a[i]);
            i++;
        } else if (a[i] > b[j]) {
            r.push(b[j]);
            j++;
        } else {
            r.push(a[i]);
            i++;
            j++;
        }
    }
    while (i < a.length) {
        r.push(a[i]);
        i++;
    }
    while (j < b.length) {
        r.push(b[j]);
        j++;
    }
    return r;
}
function intersection(a, b) {
    var r = [],
        i = 0,
        j = 0;
    while (i < a.length && j < b.length) {
        if (a[i] < b[j]) {
            i++;
        } else if (a[i] > b[j]) {
            j++;
        } else {
            r.push(a[i]);
            i++;
            j++;
        }
    }
    return r;
}<|endoftext|>


<commit_before>// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

'use strict';

module.exports = {
  opts: {
    readme: './README.md',
    package: './package.json',
    template: './node_modules/jsdoc-fresh',
    recurse: true,
    verbose: true,
    destination: './docs/'
  },
  plugins: [
    'plugins/markdown',
    'jsdoc-region-tag'
  ],
  source: {
    excludePattern: '(^|\\/|\\\\)[._]',
    include: [
      'build/src'
    ],
    includePattern: '\\.js$'
  },
  templates: {
    copyright: 'Copyright 2018 Google, LLC.',
    includeDate: false,
    sourceFiles: false,
    systemName: '@google-cloud/dns',
    theme: 'lumen'
  },
  markdown: {
    idInHeadings: true
  }
};
<commit_msg>chore: update jsdoc.js (#346)<commit_after>// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

'use strict';

module.exports = {
  opts: {
    readme: './README.md',
    package: './package.json',
    template: './node_modules/jsdoc-fresh',
    recurse: true,
    verbose: true,
    destination: './docs/'
  },
  plugins: [
    'plugins/markdown',
    'jsdoc-region-tag'
  ],
  source: {
    excludePattern: '(^|\\/|\\\\)[._]',
    include: [
      'build/src'
    ],
    includePattern: '\\.js$'
  },
  templates: {
    copyright: 'Copyright 2019 Google, LLC.',
    includeDate: false,
    sourceFiles: false,
    systemName: '@google-cloud/dns',
    theme: 'lumen',
    default: {
      "outputSourceFiles": false
    }
  },
  markdown: {
    idInHeadings: true
  }
};
<|endoftext|>


<commit_before>module.exports = {
    coverage: true,
    threshold: 90,
    lint: true
};
<commit_msg>Remove unused .labrc.js<commit_after><|endoftext|>


<commit_before>// Canvas.js
'use strict';

import React from 'react';
import d3 from 'd3';
import downloadable from './d3-downloadable';

const line = d3.svg.line()
    .x(d => d[0])
    .y(d => d[1]);

const layerAdjust = 20;

export default class Canvas extends React.Component {

    static get propTypes() {
        return {
            width: React.PropTypes.number,
            height: React.PropTypes.number,
            dataset: React.PropTypes.array,
            style: React.PropTypes.object,
            renderGrid: React.PropTypes.bool
        };
    }

    static get contextTypes() {
        return {
            emitter: React.PropTypes.object
        };
    }

    componentDidMount() {
        d3.select(this.refs.canvas).append('svg')
            .attr('width', this.props.width)
            .attr('height', this.props.height);

        let that = this;
        d3.select(this.refs.layer).on('mousemove.canvas', function() {
            const point = [d3.event.offsetX, d3.event.offsetY + 24 - layerAdjust];
            that.context.emitter.emit('mousemove.canvas', point);
        });
        d3.select(this.refs.layer).on('click', function() {
            const point = [d3.event.offsetX, d3.event.offsetY + 24 - layerAdjust];
            that.context.emitter.emit('click.canvas', point);
        });

        this.renderCanvas();
    }

    componentDidUpdate() {
        this.renderCanvas();
    }

    render() {
        let wrapperStyle = {
            position: 'relative',
            width: this.props.width,
            height: this.props.height
        };
        let cursorLayerStyle = {
            position: 'absolute',
            top: -layerAdjust,
            zIndex: 9999,
            width: this.props.width,
            height: this.props.height,
            cursor: 'url(css/ic_edit_' + this.props.strokeColor + '_24px.svg), default'
        };
        let canvasStyle = Object.assign({}, {
            position: 'absolute',
            top: 0,
            width: this.props.width,
            height: this.props.height,
            border: 'solid 2px #333',
            backgroundColor: '#f6f6f6'
        }, this.props.style);
        return (

        );
    }

    renderCanvas() {
        let svg = d3.select('svg');
        svg.call(downloadable().filename('fig'));
        svg.selectAll('path').remove();

        if (this.props.renderGrid) {
            let xCount = this.props.width / 20;
            for (var x = 0; x < xCount; x++) {
                svg.append('path')
                    .datum([[x * 20, 0], [x * 20, this.props.height]])
                    .classed('line', true)
                    .attr('d', line)
                    .attr('fill', 'none')
                    .attr('stroke', 'gray')
                    .attr('stroke-width', 1);
            }

            let yCount = this.props.height / 20;
            for (var y = 0; y < yCount; y++) {
                svg.append('path')
                    .datum([[0, y * 20], [this.props.width, y * 20]])
                    .classed('line', true)
                    .attr('d', line)
                    .attr('fill', 'none')
                    .attr('stroke', 'gray')
                    .attr('stroke-width', 1);
            }
        }

        for (var i = 0; i < this.props.dataset.length; i++) {
            var d = this.props.dataset[i];
            if (d.values.length <= 1) {
                continue;
            }
            svg.append('path')
                .datum(d.values)
                .classed('line', true)
                .attr('d', line)
                .attr('fill', 'none')
                .attr('stroke', d.strokeColor)
                .attr('stroke-width', d.strokeWidth);
        }
    }

}
<commit_msg>Apply background color to exported image file<commit_after>// Canvas.js
'use strict';

import React from 'react';
import d3 from 'd3';
import downloadable from './d3-downloadable';

const line = d3.svg.line()
    .x(d => d[0])
    .y(d => d[1]);

const layerAdjust = 20;

export default class Canvas extends React.Component {

    static get propTypes() {
        return {
            width: React.PropTypes.number,
            height: React.PropTypes.number,
            dataset: React.PropTypes.array,
            style: React.PropTypes.object,
            renderGrid: React.PropTypes.bool
        };
    }

    static get contextTypes() {
        return {
            emitter: React.PropTypes.object
        };
    }

    componentDidMount() {
        let svg = d3.select(this.refs.canvas).append('svg')
            .attr('width', this.props.width)
            .attr('height', this.props.height);

        if (this.props.style && this.props.style.backgroundColor) {
            svg.attr('style', 'background: ' + this.props.style.backgroundColor);
        } else {
            svg.attr('style', 'background: ' + '#f6f6f6');
        }

        let that = this;
        d3.select(this.refs.layer).on('mousemove.canvas', function() {
            const point = [d3.event.offsetX, d3.event.offsetY + 24 - layerAdjust];
            that.context.emitter.emit('mousemove.canvas', point);
        });
        d3.select(this.refs.layer).on('click', function() {
            const point = [d3.event.offsetX, d3.event.offsetY + 24 - layerAdjust];
            that.context.emitter.emit('click.canvas', point);
        });

        this.renderCanvas();
    }

    componentDidUpdate() {
        this.renderCanvas();
    }

    render() {
        let wrapperStyle = {
            position: 'relative',
            width: this.props.width,
            height: this.props.height
        };
        let cursorLayerStyle = {
            position: 'absolute',
            top: -layerAdjust,
            zIndex: 9999,
            width: this.props.width,
            height: this.props.height,
            cursor: 'url(css/ic_edit_' + this.props.strokeColor + '_24px.svg), default'
        };
        let canvasStyle = {
            position: 'absolute',
            top: 0,
            width: this.props.width,
            height: this.props.height,
            border: 'solid 2px #333'
        };
        return (

        );
    }

    renderCanvas() {
        let svg = d3.select('svg');
        svg.call(downloadable().filename('fig'));
        svg.selectAll('path').remove();

        if (this.props.renderGrid) {
            let xCount = this.props.width / 20;
            for (var x = 0; x < xCount; x++) {
                svg.append('path')
                    .datum([[x * 20, 0], [x * 20, this.props.height]])
                    .classed('line', true)
                    .attr('d', line)
                    .attr('fill', 'none')
                    .attr('stroke', 'gray')
                    .attr('stroke-width', 1);
            }

            let yCount = this.props.height / 20;
            for (var y = 0; y < yCount; y++) {
                svg.append('path')
                    .datum([[0, y * 20], [this.props.width, y * 20]])
                    .classed('line', true)
                    .attr('d', line)
                    .attr('fill', 'none')
                    .attr('stroke', 'gray')
                    .attr('stroke-width', 1);
            }
        }

        for (var i = 0; i < this.props.dataset.length; i++) {
            var d = this.props.dataset[i];
            if (d.values.length <= 1) {
                continue;
            }
            svg.append('path')
                .datum(d.values)
                .classed('line', true)
                .attr('d', line)
                .attr('fill', 'none')
                .attr('stroke', d.strokeColor)
                .attr('stroke-width', d.strokeWidth);
        }
    }

}
<|endoftext|>


<commit_before>define(function(require) {
  var DateTime = require('../DateTime')
  var DateFormat = require('../DateFormat')
  return {
    id             : 'LV',
    monthNames     : ['Janvāris', 'Februāris', 'Marts', 'Aprīlis', 'Maijs', 'Jūnijs', ' Jūlijs', 'Augusts', 'Septembris', 'Oktobris', 'Novembris', 'Decembris'],
    dayNames       : ['Svētdiena', ' Pirmdiena', 'Otrdiena', 'Trešdiena', 'Ceturtdiena', 'Piektdiäna', 'Sestdiena'],
    shortDayNames  : ['Svē', 'Pir', 'Otr', 'Tre', 'Cet', 'Pie', 'Ses'],
    yearsLabel     : function(years) { return years + ' ' + (years == '1' ? 'G' : 'G'); },
    monthsLabel    : function(months) { return months + ' ' + (months == '1' ? 'Mēnesī' : 'Mēnešiem') },
    daysLabel      : function(days) { return days + ' ' + (days == '1' ? 'Diena' : 'Dienas') },
    hoursLabel     : function(hours, minutes) {
      var hoursAndMinutes = DateFormat.hoursAndMinutes(hours, minutes)
      return hoursAndMinutes + ' ' + (hoursAndMinutes == '1' ? 'Stundas' : 'Minūtes')
    },
    shortDateFormat: 'j.n.Y',
    weekDateFormat : 'D j.n.Y',
    dateTimeFormat : 'D j.n.Y k\\lo G:i',
    firstWeekday   : DateTime.MONDAY
  }
})
<commit_msg>Update Friday in latvian locale<commit_after>define(function(require) {
  var DateTime = require('../DateTime')
  var DateFormat = require('../DateFormat')
  return {
    id             : 'LV',
    monthNames     : ['Janvāris', 'Februāris', 'Marts', 'Aprīlis', 'Maijs', 'Jūnijs', ' Jūlijs', 'Augusts', 'Septembris', 'Oktobris', 'Novembris', 'Decembris'],
    dayNames       : ['Svētdiena', ' Pirmdiena', 'Otrdiena', 'Trešdiena', 'Ceturtdiena', 'Piektdiena', 'Sestdiena'],
    shortDayNames  : ['Svē', 'Pir', 'Otr', 'Tre', 'Cet', 'Pie', 'Ses'],
    yearsLabel     : function(years) { return years + ' ' + (years == '1' ? 'G' : 'G'); },
    monthsLabel    : function(months) { return months + ' ' + (months == '1' ? 'Mēnesī' : 'Mēnešiem') },
    daysLabel      : function(days) { return days + ' ' + (days == '1' ? 'Diena' : 'Dienas') },
    hoursLabel     : function(hours, minutes) {
      var hoursAndMinutes = DateFormat.hoursAndMinutes(hours, minutes)
      return hoursAndMinutes + ' ' + (hoursAndMinutes == '1' ? 'Stundas' : 'Minūtes')
    },
    shortDateFormat: 'j.n.Y',
    weekDateFormat : 'D j.n.Y',
    dateTimeFormat : 'D j.n.Y k\\lo G:i',
    firstWeekday   : DateTime.MONDAY
  }
})
<|endoftext|>


<commit_before>const ICOPortfolio          = require('./ico_portfolio');
const BinarySocket          = require('../socket');
const BinaryPjax            = require('../../base/binary_pjax');
const Client                = require('../../base/client');
const localize              = require('../../base/localize').localize;
const jpClient              = require('../../common_functions/country_base').jpClient;
const getDecimalPlaces      = require('../../common_functions/currency').getDecimalPlaces;
const formatMoney           = require('../../common_functions/currency').formatMoney;
const onlyNumericOnKeypress = require('../../common_functions/event_handler');
const FormManager           = require('../../common_functions/form_manager');

const ICOSubscribe = (() => {
    const form_id = '#frm_ico_bid';
    let currency,
        $form_error,
        $duration,
        $price,
        $total;

    const onLoad = () => {
        if (jpClient()) {
            BinaryPjax.loadPreviousUrl();
            return;
        }

        BinarySocket.wait('website_status').then((response) => {
            if (response.website_status.ico_status === 'closed') {
                $(form_id).replaceWith($('<p/>', { class: 'notice-msg center-text', text: localize('The ICO auction is already closed.') }));
                ICOPortfolio.onLoad();
                $('#ico_subscribe').setVisibility(1);
            } else {
                init();
            }
        });
    };

    const init = () => {
        BinarySocket.wait('balance').then((response) => {
            ICOPortfolio.onLoad();
            currency = Client.get('currency') || '';
            if (currency) {
                $('.currency').text(currency);
            } else {
                $(form_id).find('.topMenuBalance').html(formatMoney(currency, 0));
            }
            $duration = $('#duration');
            $price    = $('#price');
            $total    = $('#total');
            calculateTotal();
            $('#ico_subscribe').setVisibility(1);

            const balance = response.balance.balance;
            if (+balance === 0) {
                $(`${form_id} input`).attr('disabled', 'disabled');
                $(form_id)
                    .on('submit', (evt) => { evt.preventDefault(); })
                    .find('button').addClass('inactive');
                $('#topup_wrapper').setVisibility(1);
            } else {
                const decimal_places = getDecimalPlaces(currency);
                $form_error          = $('#form_error');
                FormManager.init(form_id, [
                    { selector: '#duration', validations: ['req', ['number', { min: 1, max: 1000000 }]], parent_node: 'parameters' },
                    { selector: '#price',    validations: ['req', ['number', { type: 'float', decimals: `1, ${decimal_places}`, min: Math.pow(10, -decimal_places).toFixed(decimal_places), max: 999999999999999 }]] },

                    { request_field: 'buy', value: 1 },
                    { request_field: 'amount',        parent_node: 'parameters', value: () => document.getElementById('price').value },
                    { request_field: 'contract_type', parent_node: 'parameters', value: 'BINARYICO' },
                    { request_field: 'symbol',        parent_node: 'parameters', value: 'BINARYICO' },
                    { request_field: 'basis',         parent_node: 'parameters', value: 'stake' },
                    { request_field: 'currency',      parent_node: 'parameters', value: currency },
                    { request_field: 'duration_unit', parent_node: 'parameters', value: 'c' },
                ]);
                FormManager.handleSubmit({
                    form_selector       : form_id,
                    enable_button       : 1,
                    fnc_response_handler: handleResponse,
                });
                $(`${form_id} input`).on('keypress', onlyNumericOnKeypress)
                    .on('input change', calculateTotal);
            }
        });
    };

    const calculateTotal = () => {
        const duration_val = $duration.val();
        const price_val    = $price.val();
        let total          = 0;
        if (duration_val && price_val) {
            total = +duration_val * +price_val;
        }
        $total.html(formatMoney(currency, total));
    };

    const handleResponse = (response) => {
        if (response.error) {
            $form_error.text(response.error.message).setVisibility(1);
        } else {
            $form_error.setVisibility(0);
            $('#duration, #price').val('');
            $.scrollTo($('#ico_bids'), 500, { offset: -10 });
        }
    };

    const onUnload = () => {
        ICOPortfolio.onUnload();
    };

    return {
        onLoad,
        onUnload,
    };
})();

module.exports = ICOSubscribe;
<commit_msg>countDown<commit_after>const ICOPortfolio          = require('./ico_portfolio');
const BinarySocket          = require('../socket');
const BinaryPjax            = require('../../base/binary_pjax');
const Client                = require('../../base/client');
const localize              = require('../../base/localize').localize;
const jpClient              = require('../../common_functions/country_base').jpClient;
const getDecimalPlaces      = require('../../common_functions/currency').getDecimalPlaces;
const formatMoney           = require('../../common_functions/currency').formatMoney;
const onlyNumericOnKeypress = require('../../common_functions/event_handler');
const FormManager           = require('../../common_functions/form_manager');

const ICOSubscribe = (() => {
    const form_id = '#frm_ico_bid';
    let currency,
        $form_error,
        $duration,
        $price,
        $total;

    const onLoad = () => {
        if (jpClient()) {
            BinaryPjax.loadPreviousUrl();
            return;
        }

        BinarySocket.wait('website_status').then((response) => {
            if (response.website_status.ico_status === 'closed') {
                $(form_id).replaceWith($('<p/>', { class: 'notice-msg center-text', text: localize('The ICO auction is already closed.') }));
                ICOPortfolio.onLoad();
                $('#ico_subscribe').setVisibility(1);
            } else {
                init();
            }
        });
    };

    const init = () => {
        BinarySocket.wait('balance').then((response) => {
            ICOPortfolio.onLoad();
            currency = Client.get('currency') || '';
            if (currency) {
                $('.currency').text(currency);
            } else {
                $(form_id).find('.topMenuBalance').html(formatMoney(currency, 0));
            }
            $duration = $('#duration');
            $price    = $('#price');
            $total    = $('#total');
            calculateTotal();
            $('#ico_subscribe').setVisibility(1);

            const balance = response.balance.balance;
            if (+balance === 0) {
                $(`${form_id} input`).attr('disabled', 'disabled');
                $(form_id)
                    .on('submit', (evt) => { evt.preventDefault(); })
                    .find('button').addClass('inactive');
                $('#topup_wrapper').setVisibility(1);
            } else {
                const decimal_places = getDecimalPlaces(currency);
                $form_error          = $('#form_error');
                FormManager.init(form_id, [
                    { selector: '#duration', validations: ['req', ['number', { min: 1, max: 1000000 }]], parent_node: 'parameters' },
                    { selector: '#price',    validations: ['req', ['number', { type: 'float', decimals: `1, ${decimal_places}`, min: Math.pow(10, -decimal_places).toFixed(decimal_places), max: 999999999999999 }]] },

                    { request_field: 'buy', value: 1 },
                    { request_field: 'amount',        parent_node: 'parameters', value: () => document.getElementById('price').value },
                    { request_field: 'contract_type', parent_node: 'parameters', value: 'BINARYICO' },
                    { request_field: 'symbol',        parent_node: 'parameters', value: 'BINARYICO' },
                    { request_field: 'basis',         parent_node: 'parameters', value: 'stake' },
                    { request_field: 'currency',      parent_node: 'parameters', value: currency },
                    { request_field: 'duration_unit', parent_node: 'parameters', value: 'c' },
                ]);
                FormManager.handleSubmit({
                    form_selector       : form_id,
                    enable_button       : 1,
                    fnc_response_handler: handleResponse,
                });
                $(`${form_id} input`).on('keypress', onlyNumericOnKeypress)
                    .on('input change', calculateTotal);
            }
        });
    };

    const calculateTotal = () => {
        const duration_val = $duration.val();
        const price_val    = $price.val();
        let total          = 0;
        if (duration_val && price_val) {
            total = +duration_val * +price_val;
        }
        $total.html(formatMoney(currency, total));
    };

    const icoCountDown = () => {
        const start_time = 1510704000;
        const current_time = Math.round((new Date()).getTime()/1000);
        const time_left = start_time - current_time;
        if(time_left) {
            const s = time_left % 60;
            const m = Math.floor(time_left/ 60) % 60;
            const h = Math.floor(time_left / 3600) % 24;
            const days = Math.floor(time_left / (3600 * 24));
            console.log(days, h, m, s);
        }
        return;
    };

    const handleResponse = (response) => {
        if (response.error) {
            $form_error.text(response.error.message).setVisibility(1);
        } else {
            $form_error.setVisibility(0);
            $('#duration, #price').val('');
            $.scrollTo($('#ico_bids'), 500, { offset: -10 });
        }
    };

    const onUnload = () => {
        ICOPortfolio.onUnload();
    };

    return {
        onLoad,
        onUnload,
    };
})();

module.exports = ICOSubscribe;
<|endoftext|>


<commit_before>export default function maExportToCsvButton ($stateParams, Papa, notification, AdminDescription, entryFormatter, ReadQueries) {
    return {
        restrict: 'E',
        scope: {
            entity: '&',
            label: '@',
            datastore: '&'
        },
        link: function(scope) {
            scope.label = scope.label || 'EXPORT';
            scope.datastore = scope.datastore();
            scope.entity = scope.entity();
            var exportView = scope.entity.exportView();
            var listView = scope.entity.listView();
            if (exportView.fields().length === 0) {
                var exportFields = listView.exportFields();
                if (exportFields === null) {
                    exportFields = listView.fields();
                }
                exportView.fields(exportFields);
                exportView.filters(listView.filters());
                exportView.name(listView.name()); // to enable reuse of sortField
            }
            scope.has_export = exportView.fields().length > 0;
            var formatEntry = entryFormatter.getFormatter(exportView.fields());

            scope.exportToCsv = function () {
                var rawEntries;

                ReadQueries.getAll(exportView, -1, $stateParams.search, $stateParams.sortField, $stateParams.sortDir)
                    .then(response => {
                        rawEntries = response.data;
                        return rawEntries;
                    })
                    .then(rawEntries => ReadQueries.getReferenceData(exportView.fields(), rawEntries))
                    .then(referenceData => {
                        const references = exportView.getReferences();
                        for (var name in referenceData) {
                            AdminDescription.getEntryConstructor().createArrayFromRest(
                                referenceData[name],
                                [references[name].targetField()],
                                references[name].targetEntity().name(),
                                references[name].targetEntity().identifier().name()
                            ).map(entry => scope.datastore.addEntry(references[name].targetEntity().uniqueId + '_values', entry));
                        }
                    })
                    .then(function () {
                        var entries = exportView.mapEntries(rawEntries);

                        // shortcut to diplay collection of entry with included referenced values
                        scope.datastore.fillReferencesValuesFromCollection(entries, exportView.getReferences(), true);

                        var results = [];
                        for (var i = entries.length - 1; i >= 0; i--) {
                            results[i] = formatEntry(entries[i]);
                        }
                        var csv = Papa.unparse(results, listView.exportOptions());
                        var fakeLink = document.createElement('a');
                        document.body.appendChild(fakeLink);

                        fakeLink.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(csv));
                        fakeLink.setAttribute('download', scope.entity.name() + '.csv');
                        fakeLink.click();
                    }, function (error) {
                        notification.log(error.message, {addnCls: 'humane-flatty-error'});
                    });
            };
        },
        template:
`

`
    };
}

maExportToCsvButton.$inject = ['$stateParams', 'Papa', 'notification', 'AdminDescription', 'EntryFormatter', 'ReadQueries'];
<commit_msg>Allow IE11 & Edge to export CSV<commit_after>export default function maExportToCsvButton ($stateParams, Papa, notification, AdminDescription, entryFormatter, ReadQueries) {
    return {
        restrict: 'E',
        scope: {
            entity: '&',
            label: '@',
            datastore: '&'
        },
        link: function(scope) {
            scope.label = scope.label || 'EXPORT';
            scope.datastore = scope.datastore();
            scope.entity = scope.entity();
            var exportView = scope.entity.exportView();
            var listView = scope.entity.listView();
            if (exportView.fields().length === 0) {
                var exportFields = listView.exportFields();
                if (exportFields === null) {
                    exportFields = listView.fields();
                }
                exportView.fields(exportFields);
                exportView.filters(listView.filters());
                exportView.name(listView.name()); // to enable reuse of sortField
            }
            scope.has_export = exportView.fields().length > 0;
            var formatEntry = entryFormatter.getFormatter(exportView.fields());

            scope.exportToCsv = function () {
                var rawEntries;

                ReadQueries.getAll(exportView, -1, $stateParams.search, $stateParams.sortField, $stateParams.sortDir)
                    .then(response => {
                        rawEntries = response.data;
                        return rawEntries;
                    })
                    .then(rawEntries => ReadQueries.getReferenceData(exportView.fields(), rawEntries))
                    .then(referenceData => {
                        const references = exportView.getReferences();
                        for (var name in referenceData) {
                            AdminDescription.getEntryConstructor().createArrayFromRest(
                                referenceData[name],
                                [references[name].targetField()],
                                references[name].targetEntity().name(),
                                references[name].targetEntity().identifier().name()
                            ).map(entry => scope.datastore.addEntry(references[name].targetEntity().uniqueId + '_values', entry));
                        }
                    })
                    .then(function () {
                        var entries = exportView.mapEntries(rawEntries);

                        // shortcut to diplay collection of entry with included referenced values
                        scope.datastore.fillReferencesValuesFromCollection(entries, exportView.getReferences(), true);

                        var results = [];
                        for (var i = entries.length - 1; i >= 0; i--) {
                            results[i] = formatEntry(entries[i]);
                        }
                        var csv = Papa.unparse(results, listView.exportOptions());
                        var fakeLink = document.createElement('a');
                        document.body.appendChild(fakeLink);

                        const blobName = `${scope.entity.name()}.csv`;

                        if (window.navigator && window.navigator.msSaveOrOpenBlob) { // Manage IE11+ & Edge
                            var blob = new Blob([csv], { type: 'text/csv' });
                            window.navigator.msSaveOrOpenBlob(blob, blobName);
                        } else {
                            fakeLink.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(csv));
                            fakeLink.setAttribute('download', blobName);
                            fakeLink.click();
                        }
                    }, function (error) {
                        notification.log(error.message, {addnCls: 'humane-flatty-error'});
                    });
            };
        },
        template:
`

`
    };
}

maExportToCsvButton.$inject = ['$stateParams', 'Papa', 'notification', 'AdminDescription', 'EntryFormatter', 'ReadQueries'];
<|endoftext|>