📝 Documentation for CreateAttribute.cshtml

Path:
IrbyImaging/Views/AccountingImaging/CreateAttribute.cshtml


📑 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Model & Data Model
  4. Layout & ViewBag Configuration
  5. Form Structure & Key Functional Areas
    • Hidden Fields
    • Attribute Name
    • Data Type
    • Multi‐Value Toggle
    • Index Values
    • Required Toggle
    • Employee & Job Data Links
    • Document Types Selector
    • Action Buttons
  6. Syncfusion EJ2 Components Cheat Sheet
  7. Form Posting & Routing
  8. UML Diagrams
    • Class Diagram
    • Sequence Diagram
  9. Sample Usage & Screenshot Walkthrough
  10. Conclusion

🌟 Overview & Purpose

This Razor view renders the "Create Attribute Type" form in the Accounting Imaging module. It allows administrators to define new document‐indexing attributes (e.g., custom metadata fields), specifying:

  • Name of the index attribute
  • Data type (Text, Number, Date, etc.)
  • Multi‐value capability & possible values
  • Required flag
  • Links to employee or job data
  • Applicable document types

Once submitted, the form posts to the CreateAttributeType action for persistence.


🔧 Dependencies & Technologies

Technology / Library Purpose
ASP.NET Core MVC + Razor Server‐side templating & form binding
Syncfusion EJ2 (ejs-xxx) Rich UI controls (mask edit, dropdown, checkbox…)
Newtonsoft.Json JSON serialization (if needed in scripts)
HTML5 + Bootstrap 4/5 Layout & responsive grid

Imports at the top of the file:

@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2
@using Newtonsoft.Json

📦 View Model & Data Model

@model IrbyImaging.UI.Models.DocumentAttributeView

The DocumentAttributeView likely contains properties such as:

Property Type Description
ImagingType string Category of imaging (e.g., Accounting, Legal…)
IsLegal bool Toggle Legal imaging context
IsSafety bool Toggle Safety imaging context
IsIT bool Toggle IT imaging context
IsAccounting bool Toggle Accounting imaging context
IsBidding bool Toggle Bidding imaging context
… … Additional fields (AttributeName, DataType, …)

Note: The full definition resides in IrbyImaging.UI.Models.DocumentAttributeView.cs.


⚙️ Layout & ViewBag Configuration

At the top of the file, various page titles and ViewBag properties are set for display and navigation:

@{
    ViewBag.Title     = "Create Attribute Type";
    ViewBag.pTitle    = "Create Attribute Types";
    ViewBag.pageTitle = "Create Attribute Types";
    // Optional: custom layout can be overridden
    // Layout = "~/Views/Shared/_LegalLayout.cshtml";
}

📋 Form Structure & Key Functional Areas

The form is wrapped within a Bootstrap card to keep consistent styling.

<form asp-action="CreateAttributeType">
  <!-- Hidden Fields -->
  <!-- Form Groups for each Input -->
  <!-- Action Buttons -->
</form>

1. Hidden Fields

Stores context flags from the ViewModel:

@Html.HiddenFor(m => m.ImagingType)
@Html.HiddenFor(m => m.IsLegal)
@Html.HiddenFor(m => m.IsSafety)
@Html.HiddenFor(m => m.IsIT)
@Html.HiddenFor(m => m.IsAccounting)
@Html.HiddenFor(m => m.IsBidding)

2. Attribute Name

A masked text box for free‐form attribute names:

<ej-mask-edit 
    width="400px" 
    id="attributeName" 
    input-mode="@InputMode.Text" 
    watermark-text="Enter Attribute Name">
</ej-mask-edit>

3. Data Type

A dropdown list to select the underlying data type:

<ejs-dropdownlist
    width="400px"
    id="datatype"
    dataSource="@ViewBag.datatype"
    popupWidth="300px"
    placeholder="Select data type"
    popupHeight="220px">
</ejs-dropdownlist>
  • Data Source: Supplied by the controller in ViewBag.datatype.

4. Is Index Multi Value?

A checkbox to toggle multiple values:

<ejs-checkbox 
    id="multivalue" 
    name="multivalue" 
    label="MultiValue">
</ejs-checkbox>

5. Index Values

A textarea for comma‐separated values (visible only if multi‐value is enabled):

<textarea
    class="form-control"
    id="values"
    name="values"
    placeholder="Enter comma separated values for Multi Select...">
</textarea>

6. Is Index Value Required?

<ejs-checkbox 
    id="isRequired" 
    name="isRequired" 
    label="IsRequired">
</ejs-checkbox>

<ejs-checkbox
    id="employeeData"
    name="employeeData"
    label="LinkEmployeeData">
</ejs-checkbox>

<ejs-checkbox
    id="jobData"
    name="jobData"
    label="LinkJobData">
</ejs-checkbox>

9. Document Types

A multi‐select with checkboxes, grouped by category:

<ejs-multiselect
    width="600px"
    id="doctype"
    mode="CheckBox"
    popupHeight="200px"
    dataSource="@ViewBag.data">
  <e-multiselect-fields
      groupBy="Category"
      text="Type"
      value="Id">
  </e-multiselect-fields>
</ejs-multiselect>
  • Data Source: Provided via ViewBag.data.
  • Grouping: By the Category field.

10. Action Buttons

Button Description CSS Class
Back to List Navigates back to the Document Attributes listing btn btn-danger
Create Submits the form to create a new attribute btn btn-success
<a asp-action="DocumentAttributes" 
   asp-route-category="@ViewBag.category" 
   asp-controller="LegalImaging" 
   class="btn btn-danger irby-red">
   Back to List
</a>
<input type="submit" value="Create" class="btn btn-success irby-green" />

🧰 Syncfusion EJ2 Components Cheat Sheet

Component Tag Name Key Attributes
Mask Edit <ej-mask-edit> width, input-mode, watermark-text
Dropdown List <ejs-dropdownlist> dataSource, placeholder, popupWidth
Checkbox <ejs-checkbox> id, name, label
MultiSelect <ejs-multiselect> dataSource, mode="CheckBox", groupBy

🚀 Form Posting & Routing

  • HTTP Method: POST
  • Action: CreateAttributeType in AccountingImagingController
  • Route Values: None in URL; all context (ImagingType, flags) are inside hidden inputs.
<form asp-action="CreateAttributeType" method="post">
  <!-- ... -->
</form>

Upon successful creation, the controller typically redirects back to the DocumentAttributes list.


🔄 UML Diagrams

Class Diagram

classDiagram
    class DocumentAttributeView {
        +string ImagingType
        +bool IsLegal
        +bool IsSafety
        +bool IsIT
        +bool IsAccounting
        +bool IsBidding
        +string AttributeName
        +string DataType
        +bool MultiValue
        +string[] Values
        +bool IsRequired
        +bool LinkEmployeeData
        +bool LinkJobData
        +List<int> DocumentTypeIds
    }

    class AccountingImagingController {
        +ActionResult CreateAttribute()
        +ActionResult CreateAttributeType(DocumentAttributeView model)
    }

    DocumentAttributeView <|-- CreateAttribute.cshtml : binds to
    CreateAttribute.cshtml --> AccountingImagingController : posts to

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant MVCServer

    User->>Browser: Navigate to /AccountingImaging/CreateAttribute
    Browser->>MVCServer: GET /CreateAttribute
    MVCServer->>Browser: Render CreateAttribute.cshtml
    User->>Browser: Fill in form & click Create
    Browser->>MVCServer: POST /CreateAttributeType + form data
    MVCServer->>MVCServer: Validate & save to database
    MVCServer->>Browser: Redirect to /LegalImaging/DocumentAttributes?category=...

🎯 Sample Usage & Screenshot Walkthrough

  1. Navigate to the Create Attribute Type page via the Accounting Imaging menu.
  2. Enter the Index Name (e.g. “InvoiceNumber”).
  3. Select the Data Type (e.g. Text, Number).
  4. Toggle “MultiValue” if you need multiple selectable options.
  5. Provide comma‐separated Values (if multi‐value).
  6. Mark as Required or Optional.
  7. Link to Employee or Job data if applicable.
  8. Choose one or more Document Types from the multi‐select.
  9. Click Create ➡️ the server will persist and redirect back to the list.

Tip: Ensure your Syncfusion scripts & styles are loaded in _Layout.cshtml or the shared layout.


🏁 Conclusion

The CreateAttribute.cshtml view is a highly‐configurable form built with ASP.NET Core MVC and Syncfusion EJ2. It empowers administrators to extend the document indexing system by creating custom attributes with rich UI components (masked inputs, dropdowns, multiselects).

By following this documentation, developers can:

  • Understand every form field and its configuration
  • Customize or extend the form for new requirements
  • Maintain consistency in the Accounting Imaging module

🚀 Happy Coding!