📄 CreateAttribute.cshtml Documentation
Location:
IrbyImaging/Views/LegalImaging/CreateAttribute.cshtml
Purpose: Razor view for creating a new document attribute type (aka “Index Type”) in the Legal Imaging area of the application.
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model & ViewBag Data
- Page Layout & Structure
- Key Functional Areas
- Form Metadata (Hidden Fields)
- Input for Attribute Name
- Data Type Dropdown
- Multi‑Value Toggle & Values Textarea
- Required Toggle
- Employee/Job Data Links
- Document Types MultiSelect
- Action Buttons
- Detailed Control Usage
- Sample Controller Setup
- UML Sequence Diagram
- Usage Example
- Conclusion
🧐 Overview & Purpose
This Razor view renders a Create Attribute Type form that lets Legal Imaging administrators define new document attributes (also called “Index Types”). These attributes serve as metadata fields to categorize and search documents (e.g., “Case Number”, “Confidentiality Level”, etc.).
- Primary Goals
- Collect attribute details such as name, data type, options, and flags
- Allow multi‑value selection for multi‑select attributes
- Associate the attribute with one or more document types
🛠 Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| ASP.NET Core MVC Razor | Server‑side view rendering |
| Syncfusion EJ2 Controls | Rich UI components (Dropdown, Checkbox…) |
| Newtonsoft.Json | JSON serialization (if needed in scripts) |
DocumentAttributeView |
Strongly‑typed view model |
Layout: _LegalLayout.cshtml |
Shared Legal Imaging page layout |
📦 View Model & ViewBag Data
@model IrbyImaging.UI.Models.DocumentAttributeView
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2
@using Newtonsoft.Json
-
DocumentAttributeView
Represents the attribute definition being created. Contains properties like:string ImagingTypebool IsLegal, IsSafety, IsIT- (Other fields as required)
-
ViewBag.datatype
A list of available data types (e.g., Text, Number, Date, Boolean) for the<ejs-dropdownlist>. -
ViewBag.data
A grouped list of document types used by the<ejs-multiselect>control. -
Page Titles via
ViewBag:ViewBag.Title = "Create Attribute Type"; ViewBag.pTitle = "Create Attribute Types"; ViewBag.pageTitle = "Create Attribute Types";
🏗 Page Layout & Structure
@{
Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
<h2>Create Index Type</h2>
<hr />
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="col-md-4">
<!-- FORM STARTS HERE -->
</div>
</div>
</div>
</div>
</div>
- Uses a Bootstrap grid (
.row,.col-12,.col-md-4) inside a card container. - The form posts to
LegalImagingController.CreateAttributeType.
🔑 Key Functional Areas
1. Form Metadata (Hidden Fields)
@Html.HiddenFor(m => m.ImagingType)
@Html.HiddenFor(m => m.IsLegal)
@Html.HiddenFor(m => m.IsSafety)
@Html.HiddenFor(m => m.IsIT)
Keeps context of the imaging type and flags.
2. Attribute Name Input
<ej-mask-edit
id="attributeName"
width="400px"
input-mode="@InputMode.Text"
watermark-text="Enter Attribute Name">
</ej-mask-edit>
- Syncfusion MaskEdit used for free‑form text entry.
3. Data Type Dropdown
<ejs-dropdownlist
id="datatype"
width="400px"
dataSource="@ViewBag.datatype"
popupWidth="300px"
popupHeight="220px"
placeholder="Select data type">
</ejs-dropdownlist>
- Offers selection of the attribute’s underlying data type.
4. Multi‑Value Toggle & Values Textarea
<ejs-checkbox id="multivalue" label="MultiValue"></ejs-checkbox>
<textarea
id="values"
name="values"
class="form-control"
placeholder="Enter comma seperated values for Multi Select...">
</textarea>
- Checkbox enables multi-value mode.
- Textarea appears (always rendered) to list possible values (comma‑separated).
5. Required Toggle
<ejs-checkbox id="isRequired" label="IsRequired"></ejs-checkbox>
Marks the attribute as mandatory.
6. Employee/Job Data Links
<ejs-checkbox id="employeeData" label="LinkEmployeeData"></ejs-checkbox>
<ejs-checkbox id="jobData" label="LinkJobData"></ejs-checkbox>
If checked, attribute gets data populated from:
- Employee master data
- Job master data
7. Document Types MultiSelect
<ejs-multiselect
id="doctype"
width="600px"
mode="CheckBox"
popupHeight="200px"
dataSource="@ViewBag.data"
placeholder="document types">
<e-multiselect-fields
groupBy="Category"
text="Type"
value="Id">
</e-multiselect-fields>
</ejs-multiselect>
- Allows linking the new attribute to one or more document categories.
- Grouped by
Categoryproperty, displaysTypetext and tracksId.
8. Action Buttons
<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" />
- Back navigates to the attributes list page.
- Create posts new attribute to the server.
🔍 Detailed Control Usage
| Control | Syncfusion Tag | Key Properties |
|---|---|---|
| Text Input | <ej-mask-edit> |
input-mode="Text", watermark-text, width |
| Dropdown List | <ejs-dropdownlist> |
dataSource, placeholder, popupWidth/Height |
| Checkbox | <ejs-checkbox> |
id, label, name |
| MultiSelect (Checkbox) | <ejs-multiselect> |
mode="CheckBox", dataSource, <e-multiselect-fields> |
📌 Note: All Syncfusion EJ2 tags require the proper script & style bundles in the layout (_LegalLayout.cshtml).
📝 Sample Controller Setup
public class LegalImagingController : Controller
{
// GET: Show empty form
public IActionResult CreateAttribute()
{
var model = new DocumentAttributeView
{
ImagingType = "Legal",
IsLegal = true,
IsSafety = false,
IsIT = false
};
// Populate dropdown & multiselect data
ViewBag.datatype = new[] { "Text", "Number", "Date", "Boolean" };
ViewBag.data = GetDocumentTypes(); // returns List<{ Category, Type, Id }>
return View("CreateAttribute", model);
}
// POST: Handle submit
[HttpPost]
public IActionResult CreateAttributeType(DocumentAttributeView model, string[] doctype, ...)
{
if (!ModelState.IsValid) {
// Reload dropdown & multiselect data
ViewBag.datatype = ...;
ViewBag.data = ...;
return View("CreateAttribute", model);
}
// Save logic...
// Redirect to list
return RedirectToAction("DocumentAttributes", new { category = model.ImagingType });
}
}
🔄 UML Sequence Diagram
User Browser Server
| | |
| GET /LegalImaging/Create | |
|--------------------------->| |
| | ASP.NET renders CreateAttribute.cshtml
| |<--------------------------|
| | |
| User fills form & clicks Create |
|--------------------------->| |
| | Model binding to |
| | DocumentAttributeView |
| | POST /CreateAttributeType |
| |--------------------------->|
| | Validate → Save to DB |
| | Redirect to DocumentAttributes
| |<--------------------------|
|<---------------------------| |
💻 Usage Example
-
Navigate to:
/LegalImaging/CreateAttribute -
Fill in:
- Index Name: e.g., “ConfidentialityLevel”
- Data Type: “Text”
- Is Index Multi Value?: ✅
- Index Values: “Public,Internal,Restricted”
- Required?: ✅
- Link Employee Data?: ❌
- Link Job Data?: ❌
- Document Types: [✔ Contracts, ✔ Invoices]
-
Create → new attribute appears in subsequent listing.
🏁 Conclusion
This CreateAttribute.cshtml view is a rich, data‑driven form built with Syncfusion EJ2 and ASP.NET Core MVC. It empowers administrators to extend the metadata schema dynamically, enabling powerful document indexing and search capabilities in the Legal Imaging module.
Feel free to customize styles and validation logic as needed. Happy coding! 🚀