Browse Source

Delete button

pull/1/head
Sebastian 9 years ago
parent
commit
e23a928ecb
  1. 234
      src/Squidex.Events/.gitignore
  2. 2
      src/Squidex/app/features/content/pages/contents/content-item.component.html
  3. 7
      src/Squidex/app/features/schemas/pages/messages.ts
  4. 35
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.html
  5. 25
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts
  6. 16
      src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts
  7. 14
      src/Squidex/app/shared/services/schemas.service.spec.ts
  8. 7
      src/Squidex/app/shared/services/schemas.service.ts
  9. 26
      src/Squidex/app/theme/_bootstrap.scss

234
src/Squidex.Events/.gitignore

@ -1,234 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/

2
src/Squidex/app/features/content/pages/contents/content-item.component.html

@ -22,7 +22,7 @@
<a class="dropdown-item" (click)="unpublishing.emit(); $event.stopPropagation()" *ngIf="content.isPublished">
Unpublish
</a>
<a class="dropdown-item" (click)="deleting.emit(); $event.stopPropagation()">
<a class="dropdown-item dropdown-item-delete" (click)="deleting.emit(); $event.stopPropagation()">
Delete
</a>
</div>

7
src/Squidex/app/features/schemas/pages/messages.ts

@ -13,4 +13,11 @@ export class SchemaUpdated {
public readonly version: string
) {
}
}
export class SchemaDeleted {
constructor(
public readonly name: string
) {
}
}

35
src/Squidex/app/features/schemas/pages/schema/schema-page.component.html

@ -12,6 +12,17 @@
Unpublished
</button>
</div>
<div class="dropdown dropdown-options">
<button type="button" class="btn btn-simple btn-sm" (click)="editOptionsDropdown.toggle()" [class.active]="editOptionsDropdown.isOpen | async">
<i class="icon-dots"></i>
</button>
<div class="dropdown-menu" *sqxModalView="editOptionsDropdown" closeAlways="true" [@fade]>
<a class="dropdown-item dropdown-item-delete" (click)="confirmDeleteDialog.show()">
Delete
</a>
</div>
</div>
</div>
<h3 class="panel-title">
@ -66,6 +77,30 @@
</div>
</sqx-panel>
<div class="modal" *sqxModalView="confirmDeleteDialog" [@fade]>
<div class="modal-backdrop"></div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Delete schema</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="confirmDeleteDialog.hide()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Do you really want to delete the schema?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" (click)="deleteSchema()">Yes</button>
<button type="button" class="btn btn-secondary" (click)="confirmDeleteDialog.hide()">No</button>
</div>
</div>
</div>
</div>
<div class="modal" *sqxModalView="editSchemaDialog" [@fade]>
<div class="modal-backdrop"></div>
<div class="modal-dialog">

25
src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts

@ -7,7 +7,7 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import {
AddFieldDto,
@ -30,7 +30,7 @@ import {
} from 'shared';
import { SchemaPropertiesDto } from './schema-properties';
import { SchemaUpdated } from './../messages';
import { SchemaDeleted, SchemaUpdated } from './../messages';
@Component({
selector: 'sqx-schema-page',
@ -55,6 +55,9 @@ export class SchemaPageComponent extends AppComponentBase implements OnInit {
public version = new Version('');
public confirmDeleteDialog = new ModalView();
public editOptionsDropdown = new ModalView();
public editSchemaDialog = new ModalView();
public isPublished: boolean;
@ -78,7 +81,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnInit {
private readonly schemasService: SchemasService,
private readonly messageBus: MessageBus,
private readonly formBuilder: FormBuilder,
private readonly route: ActivatedRoute
private readonly route: ActivatedRoute,
private readonly router: Router
) {
super(notifications, users, apps);
}
@ -180,6 +184,21 @@ export class SchemaPageComponent extends AppComponentBase implements OnInit {
});
}
public deleteSchema() {
this.appName()
.switchMap(app => this.schemasService.deleteSchema(app, this.schemaName, this.version)).retry(2)
.finally(() => {
this.confirmDeleteDialog.hide();
})
.subscribe(() => {
this.messageBus.publish(new SchemaDeleted(this.schemaName));
this.router.navigate(['../'], { relativeTo: this.route });
}, error => {
this.notifyError(error);
});
}
public addField() {
this.addFieldFormSubmitted = true;

16
src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts

@ -26,7 +26,7 @@ import {
Version
} from 'shared';
import { SchemaUpdated } from './../messages';
import { SchemaDeleted, SchemaUpdated } from './../messages';
@Component({
selector: 'sqx-schemas-page',
@ -37,7 +37,8 @@ import { SchemaUpdated } from './../messages';
]
})
export class SchemasPageComponent extends AppComponentBase implements OnDestroy, OnInit {
private messageSubscription: Subscription;
private messageUpdatedSubscription: Subscription;
private messageDeletedSubscription: Subscription;
public addSchemaDialog = new ModalView();
@ -56,7 +57,8 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy,
}
public ngOnDestroy() {
this.messageSubscription.unsubscribe();
this.messageUpdatedSubscription.unsubscribe();
this.messageDeletedSubscription.unsubscribe();
}
public ngOnInit() {
@ -74,12 +76,18 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy,
}
});
this.messageSubscription =
this.messageUpdatedSubscription =
this.messageBus.of(SchemaUpdated)
.subscribe(m => {
this.updateSchemas(this.schemas.map(s => s.name === m.name ? updateSchema(s, this.authService, m) : s));
});
this.messageDeletedSubscription =
this.messageBus.of(SchemaDeleted)
.subscribe(m => {
this.updateSchemas(this.schemas.filter(s => s.name !== m.name));
});
this.load();
}

14
src/Squidex/app/shared/services/schemas.service.spec.ts

@ -361,4 +361,18 @@ describe('SchemasService', () => {
authService.verifyAll();
});
it('should make delete request to delete schema', () => {
authService.setup(x => x.authDelete('http://service/p/api/apps/my-app/schemas/my-schema', version))
.returns(() => Observable.of(
new Response(
new ResponseOptions()
)
))
.verifiable(Times.once());
schemasService.deleteSchema('my-app', 'my-schema', version);
authService.verifyAll();
});
});

7
src/Squidex/app/shared/services/schemas.service.ts

@ -376,4 +376,11 @@ export class SchemasService {
return this.authService.authDelete(url, version)
.catchError('Failed to delete field. Please reload.');
}
public deleteSchema(appName: string, schemaName: string, version: Version): Observable<any> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/schemas/${schemaName}`);
return this.authService.authDelete(url, version)
.catchError('Failed to delete schema. Please reload.');
}
}

26
src/Squidex/app/theme/_bootstrap.scss

@ -37,9 +37,29 @@ body {
}
.dropdown-menu {
@include box-shadow(0, 3px, 16px, .2px);
border: 0;
background: $panel-light-background;
& {
@include box-shadow(0, 3px, 16px, .2px);
border: 0;
background: $panel-light-background;
}
a {
&.dropdown-item-delete {
& {
color: $color-theme-error;
}
&:hover {
color: $color-theme-error-dark;
}
&:active {
background: $color-theme-error-dark;
border: 0;
color: $color-accent-dark;
}
}
}
}
.nav-dark {

Loading…
Cancel
Save