Skip to content

Commit

Permalink
New editor cursus
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfyWin committed Aug 21, 2024
1 parent cc0b98d commit cc20f76
Show file tree
Hide file tree
Showing 17 changed files with 657 additions and 60 deletions.
50 changes: 0 additions & 50 deletions src/plugin/cursus/Resources/modules/course/components/edit.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react'

import {trans} from '#/main/app/intl'
import {CALLBACK_BUTTON} from '#/main/app/buttons'

import {EditorActions} from '#/main/app/editor'

const CourseEditorActions = () =>
<EditorActions
actions={[
{
title: trans('archive_training', {}, 'actions'),
help: trans('archive_training_help', {}, 'actions'),
action: {
label: trans('archive', {}, 'actions'),
type: CALLBACK_BUTTON,
callback: () => false
},
managerOnly: true
}, {
title: trans('restore_training', {}, 'actions'),
help: trans('restore_training_help', {}, 'actions'),
action: {
label: trans('restore', {}, 'actions'),
type: CALLBACK_BUTTON,
callback: () => false
},
managerOnly: true
}, {
title: trans('delete_training', {}, 'actions'),
help: trans('delete_training_help', {}, 'actions'),
action: {
label: trans('delete', {}, 'actions'),
type: CALLBACK_BUTTON,
callback: () => false
},
dangerous: true,
managerOnly: true
}
]}
/>

export {
CourseEditorActions
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React from 'react'
import {PropTypes as T} from 'prop-types'

import {trans} from '#/main/app/intl'
import {EditorPage} from '#/main/app/editor'
import {DataFormSection as DataFormSectionTypes} from '#/main/app/content/form/prop-types'

const CourseEditorAppearance = (props) =>
<EditorPage
title={trans('appearance')}
help={trans('course_appearance_help', {}, 'cursus')}
definition={[
{
icon: 'fa fa-fw fa-desktop',
title: trans('display_parameters'),
primary: true,
fields: [
{
name: 'poster',
label: trans('poster'),
type: 'image'
}, {
name: 'thumbnail',
label: trans('thumbnail'),
type: 'image'
},{
name: 'display.order',
type: 'number',
label: trans('order'),
required: true,
options: {
min: 0
}
},
{
name: 'opening.session',
label: trans('opening_session', {}, 'cursus'),
type: 'choice',
required: true,
options: {
noEmpty: true,
condensed: true,
choices: {
none: trans('opening_session_none', {}, 'cursus'),
first_available: trans('opening_session_first_available', {}, 'cursus'),
default: trans('opening_session_default', {}, 'cursus')
}
},
help: trans('opening_session_help', {}, 'cursus')
}, {
name: 'display.hideSessions',
type: 'boolean',
label: trans('hide_sessions', {}, 'cursus')
}, {
name: 'restrictions.hidden',
type: 'boolean',
label: trans('restrict_hidden'),
help: trans('restrict_hidden_help')
}
]
}
].concat(props.definition)}
>
{props.children}
</EditorPage>

CourseEditorAppearance.propTypes = {
definition: T.arrayOf(T.shape(
DataFormSectionTypes.propTypes
)),
children: T.any
}

CourseEditorAppearance.defaultProps = {
definition: []
}

export {
CourseEditorAppearance
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

import {trans} from '#/main/app/intl'
import {EditorPage} from '#/main/app/editor'

import {LogOperationalList} from '#/main/log/components/operational-list'

const CourseEditorHistory = () =>
<EditorPage
title={trans('history')}
help={trans('course_history_help', {}, 'cursus')}
>
<LogOperationalList
autoload=""
url=""
/>
</EditorPage>

export {
CourseEditorHistory
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react'
import get from 'lodash/get'
import {PropTypes as T} from 'prop-types'

import {trans} from '#/main/app/intl'
import {route} from '#/plugin/cursus/routing'
import {hasPermission} from '#/main/app/security'
import {Editor} from '#/main/app/editor/components/main'
import {Course as CourseTypes} from '#/plugin/cursus/prop-types'

import {CourseEditorHistory} from '#/plugin/cursus/course/editor/components/history'
import {CourseEditorActions} from '#/plugin/cursus/course/editor/components/actions'
import {CourseEditorOverview} from '#/plugin/cursus/course/editor/components/overview'
import {CourseEditorAppearance} from '#/plugin/cursus/course/editor/components/appearance'
import {CourseEditorWorkspaces} from '#/plugin/cursus/course/editor/components/workspaces'
import {CourseEditorPermissions} from '#/plugin/cursus/course/editor/components/permissions'
import {CourseEditorRegistration} from '#/plugin/cursus/course/editor/components/registration'

import {selectors} from '#/plugin/cursus/course/store'

const CourseEditor = (props) =>
<Editor
path={route(props.course, null, props.path)+'/edit'}
title={get(props.course, 'name')}
name={selectors.FORM_NAME}
target={['apiv2_cursus_course_update', {id: props.course.id}]}
canAdministrate={hasPermission('administrate', props.course)}
close={props.path}
defaultPage="overview"
historyPage={CourseEditorHistory}
actionsPage={CourseEditorActions}
overviewPage={CourseEditorOverview}
appearancePage={CourseEditorAppearance}
permissionsPage={CourseEditorPermissions}
pages={[
{
name:'workspaces',
title: trans('workspaces'),
render: () => (
<CourseEditorWorkspaces
name={selectors.FORM_NAME}
course={props.course}
contextType={props.contextType}
update={props.update}
/>
)
}, {
name:'registration',
title: trans('registration'),
render: () => (
<CourseEditorRegistration
name={selectors.FORM_NAME}
course={props.course}
update={props.update}
/>
)
}
].concat(props.pages || [])}
/>

CourseEditor.propTypes = {
path: T.string.isRequired,
course: T.shape(
CourseTypes.propTypes
),
update: T.func.isRequired,
contextType: T.string,
pages: T.array
}

export {
CourseEditor
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from 'react'

import {trans} from '#/main/app/intl'
import {EditorPage} from '#/main/app/editor'

const CourseEditorOverview = () =>
<EditorPage
title={trans('overview')}
definition={[
{
title: trans('general'),
primary: true,
fields: [
{
name: 'poster',
type: 'poster',
label: trans('poster'),
hideLabel: true
}, {
name: 'name',
type: 'string',
label: trans('name'),
required: true
}, {
name: 'code',
type: 'string',
label: trans('code'),
required: true
}
]
}, {
title: trans('further_information'),
subtitle: trans('further_information_help'),
primary: true,
fields: [
{
name: 'parent',
type: 'training_course',
label: trans('parent')
}, {
name: 'description',
type: 'string',
label: trans('description_short'),
help: trans('course_short_desc_help', {}, 'cursus'),
options: {
long: true,
minRows: 2
}
}, {
name: 'plainDescription',
label: trans('description_long'),
type: 'html',
help: trans('course_long_desc_help', {}, 'cursus')
}, {
name: 'meta.duration',
type: 'number',
label: trans('duration'),
required: true,
options: {
min: 0,
unit: trans('hours')
}
}, {
name: 'tags',
label: trans('tags'),
type: 'tag'
}
]
}
]}
/>

export {
CourseEditorOverview
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react'

import {trans} from '#/main/app/intl'
import {EditorPage} from '#/main/app/editor'

const CourseEditorPermissions = () =>
<EditorPage
title={trans('permissions')}
help={trans('course_permissions_help', {}, 'cursus')}
managerOnly={true}
definition={[
{
name: 'public',
title: trans('public_course', {}, 'cursus'),
primary: true,
fields: [
{
name: 'meta.public',
type: 'boolean',
label: trans('make_course_public', {}, 'cursus'),
help: [
trans('make_course_public_help', {}, 'cursus')
]
}
]
},{
name: 'organizations',
title: trans('organizations'),
hideTitle: true,
primary: true,
fields: [
{
name: 'organizations',
label: trans('organizations'),
type: 'organizations'
}
]
}
]}
/>

export {
CourseEditorPermissions
}
Loading

0 comments on commit cc20f76

Please sign in to comment.