Skip to content

Commit

Permalink
feat(plugin): new Row Based Editing
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jan 20, 2024
1 parent ef08c0f commit 1f768a5
Show file tree
Hide file tree
Showing 16 changed files with 700 additions and 217 deletions.
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
},
"dependencies": {
"@ngx-translate/core": "^15.0.0",
"@slickgrid-universal/common": "~4.2.0",
"@slickgrid-universal/custom-footer-component": "~4.2.0",
"@slickgrid-universal/empty-warning-component": "~4.2.0",
"@slickgrid-universal/event-pub-sub": "~4.2.0",
"@slickgrid-universal/pagination-component": "~4.2.0",
"@slickgrid-universal/row-detail-view-plugin": "~4.2.0",
"@slickgrid-universal/rxjs-observable": "~4.2.0",
"@slickgrid-universal/common": "~4.3.0",
"@slickgrid-universal/custom-footer-component": "~4.3.0",
"@slickgrid-universal/empty-warning-component": "~4.3.0",
"@slickgrid-universal/event-pub-sub": "~4.3.0",
"@slickgrid-universal/pagination-component": "~4.3.0",
"@slickgrid-universal/row-detail-view-plugin": "~4.3.0",
"@slickgrid-universal/rxjs-observable": "~4.3.0",
"dequal": "^2.0.3",
"dompurify": "^3.0.8",
"rxjs": "^7.8.1",
Expand All @@ -65,11 +65,11 @@
"devDependencies": {
"@4tw/cypress-drag-drop": "^2.2.5",
"@angular-devkit/build-angular": "^17.1.0",
"@angular-eslint/builder": "^17.2.0",
"@angular-eslint/eslint-plugin": "^17.2.0",
"@angular-eslint/eslint-plugin-template": "^17.2.0",
"@angular-eslint/schematics": "^17.2.0",
"@angular-eslint/template-parser": "^17.2.0",
"@angular-eslint/builder": "^17.2.1",
"@angular-eslint/eslint-plugin": "^17.2.1",
"@angular-eslint/eslint-plugin-template": "^17.2.1",
"@angular-eslint/schematics": "^17.2.1",
"@angular-eslint/template-parser": "^17.2.1",
"@angular/animations": "^17.1.0",
"@angular/cli": "^17.1.0",
"@angular/common": "^17.1.0",
Expand All @@ -87,12 +87,12 @@
"@ngx-translate/http-loader": "^8.0.0",
"@popperjs/core": "^2.11.8",
"@release-it/conventional-changelog": "^8.0.1",
"@slickgrid-universal/composite-editor-component": "~4.2.0",
"@slickgrid-universal/custom-tooltip-plugin": "~4.2.0",
"@slickgrid-universal/excel-export": "~4.2.0",
"@slickgrid-universal/graphql": "~4.2.0",
"@slickgrid-universal/odata": "~4.2.0",
"@slickgrid-universal/text-export": "~4.2.0",
"@slickgrid-universal/composite-editor-component": "~4.3.0",
"@slickgrid-universal/custom-tooltip-plugin": "~4.3.0",
"@slickgrid-universal/excel-export": "~4.3.0",
"@slickgrid-universal/graphql": "~4.3.0",
"@slickgrid-universal/odata": "~4.3.0",
"@slickgrid-universal/text-export": "~4.3.0",
"@types/dompurify": "^3.0.5",
"@types/flatpickr": "^3.1.2",
"@types/fnando__sparkline": "^0.3.7",
Expand Down
2 changes: 2 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GridAddItemComponent } from './examples/grid-additem.component';
import { GridAngularComponent } from './examples/grid-angular.component';
import { GridAutoHeightComponent } from './examples/grid-autoheight.component';
import { GridBasicComponent } from './examples/grid-basic.component';
import { GridBaseRowEditingComponent } from './examples/grid-base-row-editing.component';
import { GridClientSideComponent } from './examples/grid-clientside.component';
import { GridColspanComponent } from './examples/grid-colspan.component';
import { GridCompositeEditorComponent } from './examples/grid-composite-editor.component';
Expand Down Expand Up @@ -42,6 +43,7 @@ const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'angular-components', component: GridAngularComponent },
{ path: 'additem', component: GridAddItemComponent },
{ path: 'base-row-editing', component: GridBaseRowEditingComponent },
{ path: 'autoheight', component: GridAutoHeightComponent },
{ path: 'basic', component: GridBasicComponent },
{ path: 'colspan', component: GridColspanComponent },
Expand Down
5 changes: 5 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@
34- Custom header & footer templates
</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLinkActive="active" [routerLink]="['/base-row-editing']">
35- Row Based Editing
</a>
</li>
</ul>
</section>

Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { EditorNgSelectComponent } from './examples/editor-ng-select.component';
import { FilterNgSelectComponent } from './examples/filter-ng-select.component';
import { GridAddItemComponent } from './examples/grid-additem.component';
import { GridAutoHeightComponent } from './examples/grid-autoheight.component';
import { GridBaseRowEditingComponent } from './examples/grid-base-row-editing.component';
import { GridBasicComponent } from './examples/grid-basic.component';
import { GridClientSideComponent } from './examples/grid-clientside.component';
import { GridColspanComponent } from './examples/grid-colspan.component';
Expand Down Expand Up @@ -97,6 +98,7 @@ export function appInitializerFactory(translate: TranslateService, injector: Inj
GridAddItemComponent,
GridAngularComponent,
GridAutoHeightComponent,
GridBaseRowEditingComponent,
GridBasicComponent,
GridClientSideComponent,
GridColspanComponent,
Expand Down
77 changes: 77 additions & 0 deletions src/app/examples/grid-base-row-editing.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<h2>
Example 35: Row Based Editing
<span class="float-end">
<a style="font-size: 18px"
target="_blank"
href="https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-base-row-editing.component.ts">
<span class="fa fa-link"></span> code
</a>
</span>
</h2>

<div class="subtitle">
<ul>
<li>
The Row Based Edit plugin allows you to edit either a single or multiple
specific rows at a time, while disabling the rest of the grid rows.
</li>
<li>
Editedable rows, as well as modified cells are highlighted with a
different color, which you can customize using css variables (see
<a
target="_blank"
href="https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-base-row-editing.component.scss"
>
grid-base-row-editing.component.scss </a
>)
</li>
<li>
Modifications are kept track of and if the cancel button is pressed, all
modifications are rolled back.
</li>
<li>
If the save button is pressed, a custom "onBeforeRowUpdated" callback is called, which you can use to save the data with your backend.<br />
The callback needs to return a Promise&lt;boolean&gt; and if the promise resolves to true, then the row will be updated, otherwise it will be cancelled and stays in edit mode.
You can try out the later by defining a Duration value <b>larger than 40</b>.
<br />
<small><span class="has-text-danger">NOTE:</span> You can also combine this with e.g. Batch Editing like shown <a href="#/example30">in Example 30</a></small>
</li>
<li>
This example additionally uses the ExcelCopyBuffer Plugin, which you can see also in Slickgrid-Universal
<a href="https://ghiscoding.github.io/slickgrid-universal/#/example19">example 19</a>.
The example defines a rule that pastes in the first column are prohibited. In combination with the Row Based Editing Plugin though, this rule gets enhanced with the fact
that only the edited rows are allowed to be pasted into, while still respecting the original rule.
</li>
</ul>
</div>

<section>
<div class="row mb-4">
<div class="col-sm-8">
<button
class="btn btn-outline-secondary btn-sm"
data-test="single-multi-toggle"
(click)="toggleSingleMultiRowEdit()"
>
Toggle Single/Multi Row Edit
</button>
<button class="btn btn-outline-secondary btn-sm" data-test="toggle-language" (click)="switchLanguage()">
<i class="fa fa-language"></i>
Switch Language
</button>
<b>Locale:</b> <span style="font-style: italic" data-test="selected-locale">{{selectedLanguage + '.json'}}</span>
</div>

<div class="col-sm-4" [class]="statusClass">
<strong>Status: </strong>
<span data-test="fetch-result" [textContent]="fetchResult"></span>
</div>
</div>
</section>

<angular-slickgrid gridId="grid35"
[columnDefinitions]="columnDefinitions"
[gridOptions]="gridOptions"
[dataset]="dataset"
(onAngularGridCreated)="angularGridReady($event.detail)">
</angular-slickgrid>
18 changes: 18 additions & 0 deletions src/app/examples/grid-base-row-editing.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
:root {
// turn on/off the following variables to see the difference in styling

// --slick-row-based-edit-editmode-bgcolor: rgb(82, 235, 158);
// --slick-row-based-edit-editmode-hover-bgcolor: cyan;
// --slick-row-based-edit-unsaved-cell-bgcolor: rgb(190, 114, 127);
// --slick-row-based-edit-editmode-active-bgcolor: rgb(82, 235, 158);
// --slick-row-based-edit-editmode-active-hover-bgcolor: cyan;
}

.alert {
padding: 8px;
margin-bottom: 10px
}

.status-container {
min-height: 50px;
}

0 comments on commit 1f768a5

Please sign in to comment.