đ EditAttribute.cshtml Documentation
đ Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- ViewModel & Data Model
- Layout & Page Titles
- Form Structure & Fields
- 5.1. Hidden Fields
- 5.2. Readâonly Inputs
- 5.3. Index Values TextArea
- 5.4. Document Types MultiSelect
- 5.5. Action Buttons
- Key Scripts & ClientâSide Behavior
- 6.1. MultiSelect:
onBegin,onBound - 6.2. Filtering:
onfiltering - 6.3. Ripple Effect Initialization
- 6.1. MultiSelect:
- Controller & Endpoint Overview
- UML Class Diagram
- Usage Example
- Conclusion
1. Overview & Purpose
This Razor view (EditAttribute.cshtml) is part of the IrbyImaging web application under the Views/LegalImaging folder. It provides a user interface for updating an existing document-attribute type.
đ **Key Goals:
**
- Display current attribute details (name, required/multivalue flags, linked data flags) in readâonly form.
- Allow the user to update the attributeâs index values and assign it to one or more document types.
- Submit the changes to the
EditAttributeTypeaction for serverâside processing.
2. Dependencies & Technologies
| Library / Technology | Purpose |
|---|---|
| ASP.NET Core Razor | Serverâside view engine |
Syncfusion.EJ2 JavaScript |
Rich UI components (MultiSelect) |
Newtonsoft.Json |
Serializing ViewBag.data for clientâside filtering |
| HTML5, CSS, Bootstrap 4 | Layout and responsive grid |
3. ViewModel & Data Model
Model bound to this view:
public class DocumentAttributeView {
public int Id { get; set; }
public string AttributeName { get; set; }
public bool IsMultiValue { get; set; }
public bool IsRequired { get; set; }
public bool LinkEmployeeData { get; set; }
public bool LinkJobData { get; set; }
public string Values { get; set; }
public ImagingType ImagingType { get; set; }
public bool IsLegal { get; set; }
public bool IsSafety { get; set; }
public bool IsIT { get; set; }
// (Potentially) List<int> SelectedDocumentTypeIds { get; set; }
}
Supporting Enumeration:
public enum ImagingType {
Legal,
Safety,
IT
}
4. Layout & Page Titles
@{
ViewBag.Title = "Update Attribute Type";
ViewBag.pTitle = "Update Attribute Types";
ViewBag.pageTitle = "Update Attribute Types";
Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
- Layout:
_LegalLayout.cshtmlmaintains consistent header/footer for Legal Imaging area. - ViewBag sets the browser title and onâpage headings.
5. Form Structure & Fields
<form asp-action="EditAttributeType" method="post" enctype="multipart/form-data">
@* Hidden & Readâonly fields *@
@Html.HiddenFor(m => m.ImagingType)
@Html.HiddenFor(m => m.IsLegal)
...
@Html.HiddenFor(m => m.IsIT)
<!-- Readâonly Text Inputs -->
<input type="text" id="attributeName" value="@Model.AttributeName" readonly required />
<input type="text" id="multivalue" value="@Model.IsMultiValue" readonly required />
<input type="text" id="isRequired" value="@Model.IsRequired" readonly required />
<input type="text" id="employeeData" value="@Model.LinkEmployeeData" readonly required />
<input type="text" id="jobData" value="@Model.LinkJobData" readonly required />
<!-- Editable TextArea for Index Values -->
<textarea id="indexvalues" name="indexvalues">@Model.Values</textarea>
<!-- Syncfusion MultiSelect for Document Types -->
<ejs-multiselect id="doctype"
dataSource="@ViewBag.data"
placeholder="Select Document Types"
mode="CheckBox" allowFiltering="true"
filtering="onfiltering"
actionBegin="onBegin"
dataBound="onBound"
popupHeight="200px">
<e-multiselect-fields text="Type" value="Id" groupBy="Category"></e-multiselect-fields>
</ejs-multiselect>
<!-- Buttons -->
<a asp-action="DocumentAttributes" asp-route-category="@category"
asp-controller="LegalImaging" class="btn btn-danger">Back</a>
<input type="submit" value="Update" class="btn btn-success" />
</form>
5.1 Hidden Fields
| Field | Bound Property | Purpose |
|---|---|---|
ImagingType |
Model.ImagingType |
Determines current imaging category |
IsLegal |
Model.IsLegal |
Legal flag for serverâside logic |
IsSafety |
Model.IsSafety |
Safety flag |
IsIT |
Model.IsIT |
IT flag |
modelId |
Model.Id |
Primary key for the record to update |
5.2 Readâonly Inputs
Why readâonly?
The attributes such as name or âIs Requiredâ are fixed once created; only the values and documentâtype mappings can be changed here.
| Input ID | Bound Value | Label |
|---|---|---|
attributeName |
Model.AttributeName |
Index Name |
multivalue |
Model.IsMultiValue |
Is Index Multi Value? |
isRequired |
Model.IsRequired |
Is Index Value Required? |
employeeData |
Model.LinkEmployeeData |
Link Employee Data? |
jobData |
Model.LinkJobData |
Link Job Data? |
5.3 Index Values TextArea
- ID:
indexvalues - Name:
indexvalues - Purpose: Commaâseparated (or newlineâseparated) list of valid index values.
5.4 Document Types MultiSelect
- Syncfusion EJ2
<ejs-multiselect> - DataSource:
ViewBag.data(List of{ Id, Type, Category, IsSelected }) - Features:
- CheckBox mode
- Grouped by
Category - Filtering via
onfilteringcallback - Preâselection via
onBegin/onBoundevents
5.5 Action Buttons
| Button Text | Type | Action |
|---|---|---|
| Back | Anchor | Returns to DocumentAttributes list for current category |
| Update | Submit | Posts form to EditAttributeType action |
6. Key Scripts & ClientâSide Behavior
6.1 MultiSelect: onBegin & onBound
var selected = [];
function onBegin(e) {
this.fields = {
text: 'Type',
value: 'Id',
itemCreated: function (args) {
if (args.curData.IsSelected) {
// collect preâselected IDs
if (selected.indexOf(args.curData.Id) === -1) {
selected.push(args.curData.Id);
}
}
}
};
}
function onBound(e) {
// apply initial selected values
this.value = selected;
}
Flow:
- onBegin sets up a custom
itemCreatedhandler to detectIsSelecteditems in the data source.- onBound assigns the collected IDs back to the componentâs
value.
6.2 Filtering: onfiltering
function onfiltering(e) {
var query = new ej.data.Query();
query = e.text !== ''
? query.where('Type', 'startswith', e.text, true)
: query;
e.updateData(@Html.Raw(JsonConvert.SerializeObject(ViewBag.data)), query);
}
- Dynamically filters the dropdown by
Typeproperty when the user types in the search box.
6.3 Ripple Effect Initialization
ej.base.enableRipple(true);
var inputElement = document.querySelectorAll(
'.e-input-group .e-input, .e-float-input.e-input-group input'
);
inputElement.forEach(function(el) {
el.addEventListener('focus', function () {
this.parentNode.classList.add('e-input-focus');
});
el.addEventListener('blur', function () {
this.parentNode.classList.remove('e-input-focus');
});
});
- Enables Syncfusion ârippleâ styling on focus/blur for a polished visual effect.
7. Controller & Endpoint Overview
[HttpGet]
public IActionResult EditAttributeType(int id, ImagingType imagingType) {
// Fetch DocumentAttributeView by id
return View(model);
}
[HttpPost]
public IActionResult EditAttributeType(DocumentAttributeView model,
string indexvalues,
List<int> doctype) {
// 1. Validate input
// 2. Update attribute entity
// 3. Save selected DocumentType mappings
// 4. Redirect back to DocumentAttributes listing
}
- GET
/LegalImaging/EditAttributeTypeâ Display the form - POST
/LegalImaging/EditAttributeTypeâ Process the update
8. UML Class Diagram
@startuml
class DocumentAttributeView {
+int Id
+string AttributeName
+bool IsMultiValue
+bool IsRequired
+bool LinkEmployeeData
+bool LinkJobData
+string Values
+ImagingType ImagingType
+bool IsLegal
+bool IsSafety
+bool IsIT
+List<int> SelectedDocumentTypeIds
}
enum ImagingType {
Legal
Safety
IT
}
DocumentAttributeView --> ImagingType
@enduml
Use a PlantUML renderer to visualize the above class relationships.
9. Usage Example
- Navigate to
/LegalImaging/EditAttributeType?id=42&imagingType=Legal. - Review readâonly fields (Index Name, flags).
- Adjust âIndex Valuesâ textarea (e.g. add âValueA\nValueBâ).
- Select one or more Document Types via the multiâselect dropdown.
- Click Update to apply changes.
- You are redirected back to the listing of attributes for the
legalcategory.
10. Conclusion
đŻ EditAttribute.cshtml delivers a rich, interactive form for modifying documentâattribute metadata in the Legal Imaging module.
- Syncfusion EJ2 enhances the UI with a checkboxâstyle multiselect & filtering.
- The form balances readâonly configuration with editable fields where appropriate.
- Custom scripts ensure preâselection and polished ripple effects.
By following the patterns in this view, you can extend or replicate similar forms for other imaging categories (Safety, IT) within the IrbyImaging application.
Thank you for reading! đ