You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main-declarative-settings-forms.ts 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import Vue from 'vue';
  2. import { loadState } from '@nextcloud/initial-state';
  3. import { translate as t, translatePlural as n } from '@nextcloud/l10n';
  4. import DeclarativeSection from './components/DeclarativeSettings/DeclarativeSection.vue';
  5. interface DeclarativeFormField {
  6. id: string,
  7. title: string,
  8. description: string,
  9. type: string,
  10. placeholder: string,
  11. label: string,
  12. options: Array<any>|null,
  13. value: any,
  14. default: any,
  15. }
  16. interface DeclarativeForm {
  17. id: number,
  18. priority: number,
  19. section_type: string,
  20. section_id: string,
  21. storage_type: string,
  22. title: string,
  23. description: string,
  24. doc_url: string,
  25. app: string,
  26. fields: Array<DeclarativeFormField>,
  27. }
  28. const forms = loadState('settings', 'declarative-settings-forms', []) as Array<DeclarativeForm>;
  29. console.debug('Loaded declarative forms:', forms);
  30. function renderDeclarativeSettingsSections(forms: Array<DeclarativeForm>): void {
  31. Vue.mixin({ methods: { t, n } })
  32. const DeclarativeSettingsSection = Vue.extend(<any>DeclarativeSection);
  33. for (const form of forms) {
  34. const el = `#${form.app}_${form.id}`
  35. new DeclarativeSettingsSection({
  36. el: el,
  37. propsData: {
  38. form,
  39. },
  40. })
  41. }
  42. }
  43. document.addEventListener('DOMContentLoaded', () => {
  44. renderDeclarativeSettingsSections(forms);
  45. });