From 507ddd13b8c061daea6118baa2498d9a603092a9 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 14 Oct 2014 16:10:01 -0700 Subject: [PATCH] Adding Orchard.DynamicForms. --- .../Activities/FormSubmittedActivity.cs | 65 + .../Activities/SelectDynamicForms.cs | 37 + .../Modules/Orchard.DynamicForms/AdminMenu.cs | 18 + .../Bindings/BodyPartBindings.cs | 12 + .../Bindings/TextFieldBindings.cs | 12 + .../Bindings/TitlePartBindings.cs | 12 + .../Bindings/UserPartBindings.cs | 14 + .../Controllers/AdminController.cs | 21 + .../Controllers/FormController.cs | 54 + .../Controllers/SubmissionAdminController.cs | 78 ++ .../Drivers/BindingsElementDriver.cs | 45 + .../Drivers/ButtonDriver.cs | 31 + .../Drivers/CheckboxDriver.cs | 71 + .../Drivers/CommonFormElementDriver.cs | 51 + .../Drivers/EnumerationDriver.cs | 66 + .../Drivers/FormDriver.cs | 154 ++ .../Drivers/HiddenFieldDriver.cs | 40 + .../Drivers/IpAddressFieldDriver.cs | 6 + .../Drivers/LabelDriver.cs | 36 + .../Drivers/RadioButtonDriver.cs | 46 + .../Drivers/TaxonomyDriver.cs | 133 ++ .../Drivers/TextAreaDriver.cs | 55 + .../Drivers/TextFieldDriver.cs | 81 ++ .../Drivers/UserNameFieldDriver.cs | 6 + .../Drivers/ValidationElementDriver.cs | 94 ++ .../Drivers/ValidationMessageDriver.cs | 30 + .../Drivers/ValidationSummaryDriver.cs | 7 + .../Orchard.DynamicForms/Elements/Button.cs | 14 + .../Orchard.DynamicForms/Elements/Checkbox.cs | 9 + .../Elements/Enumeration.cs | 58 + .../Orchard.DynamicForms/Elements/Form.cs | 60 + .../Elements/FormCategoryProvider.cs | 11 + .../Elements/FormElement.cs | 56 + .../Elements/HiddenField.cs | 4 + .../Elements/IpAddressField.cs | 11 + .../Orchard.DynamicForms/Elements/Label.cs | 24 + .../Elements/LabeledFormElement.cs | 15 + .../Elements/RadioButton.cs | 4 + .../Orchard.DynamicForms/Elements/Taxonomy.cs | 30 + .../Orchard.DynamicForms/Elements/TextArea.cs | 15 + .../Elements/TextField.cs | 9 + .../Elements/UserNameField.cs | 11 + .../Elements/ValidationMessage.cs | 13 + .../Elements/ValidationSummary.cs | 13 + .../Forms/AutoLabelForm.cs | 30 + ...ClientValidationRegistrationCoordinator.cs | 45 + .../Handlers/FormSubmissionCoordinator.cs | 52 + .../Handlers/IpAddressFieldHandler.cs | 23 + .../Handlers/ReadFormValuesHandler.cs | 29 + .../Handlers/UserNameFieldHandler.cs | 22 + .../Handlers/ValidatorsCoordinator.cs | 30 + .../ContentTypeDefinitionExtensions.cs | 9 + .../Helpers/DataTableExtensions.cs | 39 + .../Helpers/FieldValidatorsExtensions.cs | 11 + .../Helpers/FormControllerExtensions.cs | 36 + .../Helpers/NameValueCollectionExtensions.cs | 12 + .../Helpers/StreamExtensions.cs | 10 + .../Helpers/SubmissionExtensions.cs | 11 + .../Helpers/TokenizerExtensions.cs | 18 + .../ImportExport/FormsExportHandler.cs | 51 + .../ImportExport/FormsExportStep.cs | 16 + .../ImportExport/FormsImportHandler.cs | 39 + .../Orchard.DynamicForms/Migrations.cs | 62 + .../Orchard.DynamicForms/Models/Submission.cs | 13 + .../Modules/Orchard.DynamicForms/Module.txt | 23 + .../Orchard.DynamicForms.csproj | 392 ++++++ .../Orchard.DynamicForms/Permissions.cs | 57 + .../Properties/AssemblyInfo.cs | 37 + .../Orchard.DynamicForms/Scripts/Web.config | 16 + .../Scripts/jquery.validate.js | 1245 +++++++++++++++++ .../Scripts/jquery.validate.min.js | 16 + .../jquery.validate.unobtrusive.additional.js | 3 + .../Scripts/jquery.validate.unobtrusive.js | 410 ++++++ .../jquery.validate.unobtrusive.min.js | 19 + .../Services/BindingManager.cs | 48 + .../Services/ElementValidator.cs | 18 + .../Services/FormElementEventHandlerBase.cs | 9 + .../Services/FormEventHandlerBase.cs | 9 + .../Services/FormService.cs | 350 +++++ .../Services/IBindingManager.cs | 10 + .../Services/IBindingProvider.cs | 8 + .../Services/IElementValidator.cs | 8 + .../Services/IFormElementEventHandler.cs | 10 + .../Services/IFormEventHandler.cs | 10 + .../Services/IFormService.cs | 35 + .../Services/ITempDataAccessor.cs | 8 + .../Services/Models/BindingContext.cs | 33 + .../Services/Models/BindingDescribeContext.cs | 21 + .../Services/Models/BindingDescriptor.cs | 11 + .../Models/ContentFieldBindingDescriptor.cs | 12 + .../Models/ContentPartBindingDescriptor.cs | 14 + .../Models/FieldValidatorDescriptor.cs | 7 + .../Services/Models/FormEventContext.cs | 12 + .../Models/FormSubmittedEventContext.cs | 4 + .../Models/FormValidatedEventContext.cs | 7 + .../Models/FormValidatingEventContext.cs | 7 + ...rClientValidationAttributesEventContext.cs | 13 + .../Services/Models/ValidateInputContext.cs | 11 + .../Services/ReadElementValuesContext.cs | 12 + .../Orchard.DynamicForms/Styles/Web.config | 16 + .../Styles/form-elements.css | 25 + .../Styles/form.designer.css | 46 + .../Styles/forms-admin.css | 18 + .../Styles/menu.dynamicforms-admin.css | 7 + .../Styles/menu.dynamicforms.png | Bin 0 -> 381 bytes .../Validators/CheckBoxValidator.cs | 41 + .../Settings/CheckBoxValidationSettings.cs | 5 + .../Settings/TextFieldValidationSettings.cs | 7 + .../Settings/ValidationSettingsBase.cs | 6 + .../Validators/TextFieldValidator.cs | 56 + .../ViewModels/BindingSettings.cs | 6 + .../ViewModels/BlueprintsIndexViewModel.cs | 9 + .../ViewModels/FieldBindingSettings.cs | 12 + .../ViewModels/FieldValidationSettings.cs | 12 + .../ViewModels/FormBindingSettings.cs | 13 + .../ViewModels/FormsIndexViewModel.cs | 9 + .../ViewModels/PartBindingSettings.cs | 14 + .../ViewModels/SubmissionViewModel.cs | 9 + .../ViewModels/SubmissionsIndexViewModel.cs | 9 + .../Activity-DynamicFormSubmitted.cshtml | 9 + .../Views/Admin/Index.cshtml | 34 + .../Views/BlueprintAdmin/Index.cshtml | 42 + .../Views/EditorTemplates/FormBindings.cshtml | 60 + .../Views/Element-Form-Button.cshtml | 12 + .../Views/Element-Form-Checkbox.Design.cshtml | 20 + .../Views/Element-Form-Checkbox.cshtml | 24 + .../Element-Form-Enumeration-CheckList.cshtml | 20 + ...nt-Form-Enumeration-MultiSelectList.cshtml | 14 + .../Element-Form-Enumeration-RadioList.cshtml | 20 + ...Element-Form-Enumeration-SelectList.cshtml | 14 + .../Element-Form-HiddenField.Design.cshtml | 5 + .../Views/Element-Form-HiddenField.cshtml | 14 + .../Element-Form-IpAddressField.Design.cshtml | 1 + .../Views/Element-Form-IpAddressField.cshtml | 1 + .../Views/Element-Form-Label.cshtml | 12 + .../Element-Form-RadioButton.Design.cshtml | 20 + .../Views/Element-Form-RadioButton.cshtml | 20 + .../Element-Form-Taxonomy-CheckList.cshtml | 20 + ...ement-Form-Taxonomy-MultiSelectList.cshtml | 14 + .../Element-Form-Taxonomy-RadioList.cshtml | 20 + .../Element-Form-Taxonomy-SelectList.cshtml | 14 + .../Views/Element-Form-TextArea.Design.cshtml | 32 + .../Views/Element-Form-TextArea.cshtml | 32 + .../Element-Form-TextField.Design.cshtml | 24 + .../Views/Element-Form-TextField.cshtml | 27 + .../Element-Form-UserNameField.Design.cshtml | 1 + .../Views/Element-Form-UserNameField.cshtml | 1 + ...ement-Form-ValidationMessage.Design.cshtml | 4 + .../Element-Form-ValidationMessage.cshtml | 6 + ...ement-Form-ValidationSummary.Design.cshtml | 1 + .../Element-Form-ValidationSummary.cshtml | 1 + .../Views/Element-Form.Design.cshtml | 35 + .../Views/Element-Form.cshtml | 36 + .../Views/FormElement.Wrapper.cshtml | 10 + .../Views/SubmissionAdmin/Details.cshtml | 32 + .../Views/SubmissionAdmin/Index.cshtml | 53 + .../Modules/Orchard.DynamicForms/Web.config | 47 + src/Orchard.sln | 13 + 158 files changed, 6180 insertions(+) create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/FormSubmittedActivity.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/SelectDynamicForms.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/AdminMenu.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/BodyPartBindings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TextFieldBindings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TitlePartBindings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/UserPartBindings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/AdminController.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/FormController.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/SubmissionAdminController.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/BindingsElementDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/ButtonDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/CheckboxDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/CommonFormElementDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/EnumerationDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/FormDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/HiddenFieldDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/IpAddressFieldDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/LabelDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/RadioButtonDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/TaxonomyDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/TextAreaDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/TextFieldDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/UserNameFieldDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/ValidationElementDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/ValidationMessageDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/ValidationSummaryDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/Button.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/Checkbox.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/Enumeration.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/Form.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/FormCategoryProvider.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/FormElement.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/HiddenField.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/IpAddressField.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/Label.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/LabeledFormElement.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/RadioButton.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/Taxonomy.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/TextArea.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/TextField.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/UserNameField.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/ValidationMessage.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Elements/ValidationSummary.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Forms/AutoLabelForm.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Handlers/ClientValidationRegistrationCoordinator.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Handlers/FormSubmissionCoordinator.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Handlers/IpAddressFieldHandler.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Handlers/ReadFormValuesHandler.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Handlers/UserNameFieldHandler.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Handlers/ValidatorsCoordinator.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/ContentTypeDefinitionExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/DataTableExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/FieldValidatorsExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/FormControllerExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/NameValueCollectionExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/StreamExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/SubmissionExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Helpers/TokenizerExtensions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ImportExport/FormsExportHandler.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ImportExport/FormsExportStep.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ImportExport/FormsImportHandler.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Migrations.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Models/Submission.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Module.txt create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Orchard.DynamicForms.csproj create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Permissions.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Properties/AssemblyInfo.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Scripts/Web.config create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Scripts/jquery.validate.js create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Scripts/jquery.validate.min.js create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Scripts/jquery.validate.unobtrusive.additional.js create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Scripts/jquery.validate.unobtrusive.js create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Scripts/jquery.validate.unobtrusive.min.js create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/BindingManager.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/ElementValidator.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/FormElementEventHandlerBase.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/FormEventHandlerBase.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/FormService.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/IBindingManager.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/IBindingProvider.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/IElementValidator.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/IFormElementEventHandler.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/IFormEventHandler.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/IFormService.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/ITempDataAccessor.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/BindingContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/BindingDescribeContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/BindingDescriptor.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/ContentFieldBindingDescriptor.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/ContentPartBindingDescriptor.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/FieldValidatorDescriptor.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/FormEventContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/FormSubmittedEventContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/FormValidatedEventContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/FormValidatingEventContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/RegisterClientValidationAttributesEventContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/Models/ValidateInputContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Services/ReadElementValuesContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/Web.config create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/form-elements.css create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/form.designer.css create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/forms-admin.css create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/menu.dynamicforms-admin.css create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/menu.dynamicforms.png create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Validators/CheckBoxValidator.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Validators/Settings/CheckBoxValidationSettings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Validators/Settings/TextFieldValidationSettings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Validators/Settings/ValidationSettingsBase.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Validators/TextFieldValidator.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/BindingSettings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/BlueprintsIndexViewModel.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FieldBindingSettings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FieldValidationSettings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FormBindingSettings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FormsIndexViewModel.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/PartBindingSettings.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/SubmissionViewModel.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/SubmissionsIndexViewModel.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Activity-DynamicFormSubmitted.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Admin/Index.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/BlueprintAdmin/Index.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/EditorTemplates/FormBindings.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Button.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Checkbox.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Checkbox.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Enumeration-CheckList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Enumeration-MultiSelectList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Enumeration-RadioList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Enumeration-SelectList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-HiddenField.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-HiddenField.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-IpAddressField.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-IpAddressField.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Label.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-RadioButton.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-RadioButton.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Taxonomy-CheckList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Taxonomy-MultiSelectList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Taxonomy-RadioList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-Taxonomy-SelectList.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-TextArea.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-TextArea.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-TextField.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-TextField.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-UserNameField.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-UserNameField.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-ValidationMessage.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-ValidationMessage.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-ValidationSummary.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form-ValidationSummary.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form.Design.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Element-Form.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/FormElement.Wrapper.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/SubmissionAdmin/Details.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/SubmissionAdmin/Index.cshtml create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/FormSubmittedActivity.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/FormSubmittedActivity.cs new file mode 100644 index 000000000..f051ebcbe --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/FormSubmittedActivity.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Orchard.DynamicForms.Elements; +using Orchard.Localization; +using Orchard.Workflows.Models; +using Orchard.Workflows.Services; + +namespace Orchard.DynamicForms.Activities { + public class FormSubmittedActivity : Event { + + public const string EventName = "DynamicFormSubmitted"; + + public Localizer T { get; set; } + + public override bool CanStartWorkflow { + get { return true; } + } + + public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { + var state = activityContext.GetState("DynamicForms"); + + // "" means 'any'. + if (String.IsNullOrEmpty(state)) { + return true; + } + + var form = workflowContext.Tokens["DynamicForm"] as Form; + + if (form == null) { + return false; + } + + var formNames = state.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + return formNames.Any(x => x == form.Name); + } + + public override IEnumerable GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) { + return new[] { T("Done") }; + } + + public override IEnumerable Execute(WorkflowContext workflowContext, ActivityContext activityContext) { + yield return T("Done"); + } + + public override string Form { + get { + return "SelectDynamicForms"; + } + } + + public override string Name { + get { return EventName; } + } + + public override LocalizedString Category { + get { return T("Forms"); } + } + + public override LocalizedString Description { + get { return T("A dynamic form is submitted."); } + } + } + +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/SelectDynamicForms.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/SelectDynamicForms.cs new file mode 100644 index 000000000..e7ce09fb8 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Activities/SelectDynamicForms.cs @@ -0,0 +1,37 @@ +using System; +using System.Linq; +using System.Web.Mvc; +using Orchard.ContentManagement; +using Orchard.DisplayManagement; +using Orchard.Forms.Services; +using Orchard.Localization; + +namespace Orchard.DynamicForms.Activities { + public class SelectDynamicForms : IFormProvider { + protected dynamic Shape { get; set; } + public Localizer T { get; set; } + + public SelectDynamicForms(IShapeFactory shapeFactory) { + Shape = shapeFactory; + T = NullLocalizer.Instance; + } + + public void Describe(DescribeContext context) { + context.Form("SelectDynamicForms", factory => { + var shape = (dynamic)factory; + var form = shape.Form( + Id: "AnyOfDynamicForms", + _Parts: Shape.Textbox( + Id: "dynamicforms", + Name: "DynamicForms", + Title: T("Dynamic Forms"), + Description: T("Enter a comma separated list of dynamic form names. Leave empty to handle all forms."), + Classes: new[] { "text", "large" }) + ); + + return form; + }); + + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/AdminMenu.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/AdminMenu.cs new file mode 100644 index 000000000..9b6a0de82 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/AdminMenu.cs @@ -0,0 +1,18 @@ +using Orchard.UI.Navigation; + +namespace Orchard.DynamicForms { + public class AdminMenu : Component, INavigationProvider { + public string MenuName { get { return "admin"; } } + + public void GetNavigation(NavigationBuilder builder) { + builder + .AddImageSet("dynamicforms") + .Add(T("Dynamic Forms"), "4", menu => menu + .Add(T("Manage Forms"), "1.0", + item => item + .Action("Index", "Admin", new { area = "Orchard.DynamicForms" }) + .Permission(Permissions.ManageForms)) + ); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/BodyPartBindings.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/BodyPartBindings.cs new file mode 100644 index 000000000..c5d0b7d92 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/BodyPartBindings.cs @@ -0,0 +1,12 @@ +using Orchard.Core.Common.Models; +using Orchard.DynamicForms.Services; +using Orchard.DynamicForms.Services.Models; + +namespace Orchard.DynamicForms.Bindings { + public class BodyPartBindings : Component, IBindingProvider { + public void Describe(BindingDescribeContext context) { + context.For() + .Binding("Text", (part, s) => part.Text = s); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TextFieldBindings.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TextFieldBindings.cs new file mode 100644 index 000000000..eb81f1dc6 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TextFieldBindings.cs @@ -0,0 +1,12 @@ +using Orchard.Core.Common.Fields; +using Orchard.DynamicForms.Services; +using Orchard.DynamicForms.Services.Models; + +namespace Orchard.DynamicForms.Bindings { + public class TextFieldBindings : Component, IBindingProvider { + public void Describe(BindingDescribeContext context) { + context.For() + .Binding("Text", (field, s) => field.Value = s); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TitlePartBindings.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TitlePartBindings.cs new file mode 100644 index 000000000..b4cadb80f --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/TitlePartBindings.cs @@ -0,0 +1,12 @@ +using Orchard.Core.Title.Models; +using Orchard.DynamicForms.Services; +using Orchard.DynamicForms.Services.Models; + +namespace Orchard.DynamicForms.Bindings { + public class TitlePartBindings : Component, IBindingProvider { + public void Describe(BindingDescribeContext context) { + context.For() + .Binding("Title", (part, s) => part.Title = s); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/UserPartBindings.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/UserPartBindings.cs new file mode 100644 index 000000000..ec0d3e9cb --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Bindings/UserPartBindings.cs @@ -0,0 +1,14 @@ +using Orchard.DynamicForms.Services; +using Orchard.DynamicForms.Services.Models; +using Orchard.Users.Models; + +namespace Orchard.DynamicForms.Bindings { + public class UserPartBindings : Component, IBindingProvider { + public void Describe(BindingDescribeContext context) { + context.For() + .Binding("UserName", (part, s) => part.UserName = s) + .Binding("Email", (part, s) => part.Email = s) + .Binding("Password", (part, s) => part.Password = s); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/AdminController.cs new file mode 100644 index 000000000..e576341f7 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/AdminController.cs @@ -0,0 +1,21 @@ +using System.Linq; +using System.Web.Mvc; +using Orchard.DynamicForms.Services; +using Orchard.DynamicForms.ViewModels; + +namespace Orchard.DynamicForms.Controllers { + public class AdminController : Controller { + private readonly IFormService _formService; + public AdminController(IFormService formService) { + _formService = formService; + } + + public ActionResult Index() { + var forms = _formService.GetSubmissions().ToArray().GroupBy(x => x.FormName).ToArray(); + var viewModel = new FormsIndexViewModel { + Forms = forms + }; + return View(viewModel); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/FormController.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/FormController.cs new file mode 100644 index 000000000..4034f562a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/FormController.cs @@ -0,0 +1,54 @@ +using System; +using System.Web.Mvc; +using Orchard.DynamicForms.Helpers; +using Orchard.DynamicForms.Services; +using Orchard.Layouts.Services; +using Orchard.Localization; +using Orchard.Logging; +using Orchard.UI.Notify; +using IController = Orchard.DynamicForms.Services.IController; + +namespace Orchard.DynamicForms.Controllers { + public class FormController : Controller, IController { + private readonly INotifier _notifier; + private readonly ILayoutManager _layoutManager; + private readonly IFormService _formService; + + public FormController( + INotifier notifier, + ILayoutManager layoutManager, + IFormService formService) { + + _notifier = notifier; + _layoutManager = layoutManager; + _formService = formService; + T = NullLocalizer.Instance; + Logger = NullLogger.Instance; + } + + public Localizer T { get; set; } + public ILogger Logger { get; set; } + + public ActionResult Submit(int contentId, string formName) { + var layoutPart = _layoutManager.GetLayout(contentId); + var form = _formService.FindForm(layoutPart, formName); + var urlReferrer = HttpContext.Request.UrlReferrer != null ? HttpContext.Request.UrlReferrer.ToString() : "~/"; + + if (form == null) { + Logger.Warning("The specified form \"{0}\" could not be found.", formName); + _notifier.Warning(T("The specified form \"{0}\" could not be found.")); + return Redirect(urlReferrer); + } + + var values = _formService.SubmitForm(form, ValueProvider, ModelState); + this.TransferFormSubmission(form, values); + + if(Response.IsRequestBeingRedirected) + return new EmptyResult(); + + var redirectUrl = !String.IsNullOrWhiteSpace(form.RedirectUrl) ? form.RedirectUrl : urlReferrer; + return Redirect(redirectUrl); + } + + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/SubmissionAdminController.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/SubmissionAdminController.cs new file mode 100644 index 000000000..956d78c35 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Controllers/SubmissionAdminController.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; +using System.Linq; +using System.Web.Mvc; +using Orchard.DynamicForms.Helpers; +using Orchard.DynamicForms.Services; +using Orchard.DynamicForms.ViewModels; +using Orchard.Localization; +using Orchard.Mvc; +using Orchard.UI.Admin; +using Orchard.UI.Navigation; +using Orchard.UI.Notify; + +namespace Orchard.DynamicForms.Controllers { + [Admin] + public class SubmissionAdminController : Controller { + private readonly IFormService _formService; + private readonly IOrchardServices _services; + + public SubmissionAdminController(IFormService formService, IOrchardServices services) { + _formService = formService; + _services = services; + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + public ActionResult Index(string id, PagerParameters pagerParameters) { + var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters); + var submissions = _formService.GetSubmissions(id, pager.GetStartIndex(), pager.PageSize); + var pagerShape = _services.New.Pager(pager).TotalItemCount(submissions.TotalItemCount); + var viewModel = new SubmissionsIndexViewModel { + FormName = id, + Submissions = _formService.GenerateDataTable(submissions), + Pager = pagerShape + }; + return View(viewModel); + } + + public ActionResult Details(int id) { + var submission = _formService.GetSubmission(id); + + if (submission == null) + return HttpNotFound(); + + var viewModel = new SubmissionViewModel { + Submission = submission, + NameValues = submission.ToNameValues() + }; + return View(viewModel); + } + + public ActionResult Delete(int id) { + var submission = _formService.GetSubmission(id); + + if (submission == null) + return HttpNotFound(); + + _formService.DeleteSubmission(submission); + _services.Notifier.Information(T("That submission has been deleted.")); + return Redirect(Request.UrlReferrer.ToString()); + } + + [FormValueRequired("submit.BulkEdit")] + [ActionName("Index")] + public ActionResult BulkDelete(IEnumerable submissionIds) { + if (submissionIds == null || !submissionIds.Any()) { + _services.Notifier.Error(T("Please select the submissions to delete.")); + + } + else { + var numDeletedSubmissions = _formService.DeleteSubmissions(submissionIds); + _services.Notifier.Information(T("{0} submissions have been deleted.", numDeletedSubmissions)); + } + + return Redirect(Request.UrlReferrer.ToString()); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/BindingsElementDriver.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/BindingsElementDriver.cs new file mode 100644 index 000000000..8f4fd3553 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/BindingsElementDriver.cs @@ -0,0 +1,45 @@ +using System; +using System.Linq; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.DynamicForms.Elements; +using Orchard.DynamicForms.Services; +using Orchard.DynamicForms.ViewModels; +using Orchard.Layouts.Framework.Drivers; + +namespace Orchard.DynamicForms.Drivers { + public class BindingsElementDriver : ElementDriver { + private readonly IBindingManager _bindingManager; + private readonly IContentDefinitionManager _contentDefinitionManager; + + public BindingsElementDriver( + IBindingManager bindingManager, + IContentDefinitionManager contentDefinitionManager) { + + _bindingManager = bindingManager; + _contentDefinitionManager = contentDefinitionManager; + } + + protected override EditorResult OnBuildEditor(FormElement element, ElementEditorContext context) { + var contentType = element.FormBindingContentType; + var contentTypeDefinition = !String.IsNullOrWhiteSpace(contentType) ? _contentDefinitionManager.GetTypeDefinition(contentType) : default(ContentTypeDefinition); + + if (contentTypeDefinition == null) + return null; + + var viewModel = new FormBindingSettings { + AvailableBindings = _bindingManager.DescribeBindingsFor(contentTypeDefinition).ToArray() + }; + + if (context.Updater != null) { + context.Updater.TryUpdateModel(viewModel, null, null, new[] {"AvailableBindings"}); + } + + var bindingsEditor = context.ShapeFactory.EditorTemplate(TemplateName: "FormBindings", Model: viewModel); + + bindingsEditor.Metadata.Position = "Bindings:10"; + + return Editor(context, bindingsEditor); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/ButtonDriver.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/ButtonDriver.cs new file mode 100644 index 000000000..f6c06b287 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Drivers/ButtonDriver.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Orchard.DynamicForms.Elements; +using Orchard.Forms.Services; +using Orchard.Layouts.Framework.Drivers; + +namespace Orchard.DynamicForms.Drivers { + public class ButtonDriver : FormsElementDriver