[web] Add new admin tool for surveys (#8356)
* Setup survey module and admin page skeleton * Replace survey staff access permission with admin-only * Manage survey config with admin tool * Display configurable survey in project list + add preview in admin * Fix linting errors and unit tests * Add acceptance tests for survey module * Move survey-form to survey components * Add configuration option for Recurly group subscription users on surveys * Change survey pre-link text to a lighter gray for accessibility * Cleanup survey options implementation after review GitOrigin-RevId: 8f621951efeae458d1ab081fe98b8d0d539cca1a
This commit is contained in:
committed by
Copybot
parent
21c8b9a47a
commit
3d26c4bb6f
@@ -0,0 +1,49 @@
|
||||
const mongoose = require('../infrastructure/Mongoose')
|
||||
const { Schema } = mongoose
|
||||
|
||||
const MIN_NAME_LENGTH = 3
|
||||
const MAX_NAME_LENGTH = 200
|
||||
const NAME_REGEX = /^[a-z0-9-]+$/
|
||||
|
||||
const SurveySchema = new Schema(
|
||||
{
|
||||
name: {
|
||||
type: String,
|
||||
minLength: MIN_NAME_LENGTH,
|
||||
maxlength: MAX_NAME_LENGTH,
|
||||
required: true,
|
||||
validate: {
|
||||
validator: function (input) {
|
||||
return input !== null && NAME_REGEX.test(input)
|
||||
},
|
||||
message: `invalid, must match: ${NAME_REGEX}`,
|
||||
},
|
||||
},
|
||||
preText: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
linkText: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
options: {
|
||||
hasRecurlyGroupSubscription: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
collection: 'surveys',
|
||||
}
|
||||
)
|
||||
|
||||
module.exports = {
|
||||
Survey: mongoose.model('Survey', SurveySchema),
|
||||
SurveySchema,
|
||||
}
|
||||
Reference in New Issue
Block a user