From fcc760a3c9e08f087c798ccf296589b7b4952f4a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 18 Jan 2017 23:44:02 +0100 Subject: [PATCH] Publishing --- .../Contents/ContentPublished.cs | 18 +++++ .../Contents/ContentUnpublished.cs | 18 +++++ .../Contents/Commands/PublishContent.cs | 14 ++++ .../Contents/Commands/UnpublishContent.cs | 14 ++++ .../contents/content-item.component.html | 30 ++++++++ .../contents/content-item.component.scss | 61 ++++++++++++++++ .../pages/contents/content-item.component.ts | 73 +++++++++++++++++++ 7 files changed, 228 insertions(+) create mode 100644 src/Squidex.Events/Contents/ContentPublished.cs create mode 100644 src/Squidex.Events/Contents/ContentUnpublished.cs create mode 100644 src/Squidex.Write/Contents/Commands/PublishContent.cs create mode 100644 src/Squidex.Write/Contents/Commands/UnpublishContent.cs create mode 100644 src/Squidex/app/features/content/pages/contents/content-item.component.html create mode 100644 src/Squidex/app/features/content/pages/contents/content-item.component.scss create mode 100644 src/Squidex/app/features/content/pages/contents/content-item.component.ts diff --git a/src/Squidex.Events/Contents/ContentPublished.cs b/src/Squidex.Events/Contents/ContentPublished.cs new file mode 100644 index 000000000..c352396c0 --- /dev/null +++ b/src/Squidex.Events/Contents/ContentPublished.cs @@ -0,0 +1,18 @@ +// ========================================================================== +// ContentPublished.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +using Squidex.Infrastructure; +using Squidex.Infrastructure.CQRS.Events; + +namespace Squidex.Events.Contents +{ + [TypeName("ContentPublishedEvent")] + public class ContentPublished : IEvent + { + } +} diff --git a/src/Squidex.Events/Contents/ContentUnpublished.cs b/src/Squidex.Events/Contents/ContentUnpublished.cs new file mode 100644 index 000000000..f3b8d02b5 --- /dev/null +++ b/src/Squidex.Events/Contents/ContentUnpublished.cs @@ -0,0 +1,18 @@ +// ========================================================================== +// ContentUnpublished.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +using Squidex.Infrastructure; +using Squidex.Infrastructure.CQRS.Events; + +namespace Squidex.Events.Contents +{ + [TypeName("ContentUnpublishedEvent")] + public class ContentUnpublished : IEvent + { + } +} diff --git a/src/Squidex.Write/Contents/Commands/PublishContent.cs b/src/Squidex.Write/Contents/Commands/PublishContent.cs new file mode 100644 index 000000000..49f46825c --- /dev/null +++ b/src/Squidex.Write/Contents/Commands/PublishContent.cs @@ -0,0 +1,14 @@ +// ========================================================================== +// PublishContent.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +namespace Squidex.Write.Contents.Commands +{ + public class PublishContent : SchemaCommand + { + } +} diff --git a/src/Squidex.Write/Contents/Commands/UnpublishContent.cs b/src/Squidex.Write/Contents/Commands/UnpublishContent.cs new file mode 100644 index 000000000..ca44644a4 --- /dev/null +++ b/src/Squidex.Write/Contents/Commands/UnpublishContent.cs @@ -0,0 +1,14 @@ +// ========================================================================== +// UnpublishContent.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +namespace Squidex.Write.Contents.Commands +{ + public class UnpublishContent : SchemaCommand + { + } +} diff --git a/src/Squidex/app/features/content/pages/contents/content-item.component.html b/src/Squidex/app/features/content/pages/contents/content-item.component.html new file mode 100644 index 000000000..44d14eb31 --- /dev/null +++ b/src/Squidex/app/features/content/pages/contents/content-item.component.html @@ -0,0 +1,30 @@ + + + {{getValue(field)}} + + + + + {{content.lastModified | fromNow}} + + + + + + + \ No newline at end of file diff --git a/src/Squidex/app/features/content/pages/contents/content-item.component.scss b/src/Squidex/app/features/content/pages/contents/content-item.component.scss new file mode 100644 index 000000000..8b3cfb162 --- /dev/null +++ b/src/Squidex/app/features/content/pages/contents/content-item.component.scss @@ -0,0 +1,61 @@ +@import '_vars'; +@import '_mixins'; + +.field { + @include truncate; +} + +.dropdown { + & { + display: inline-block; + } + + &-menu { + @include absolute(100%, 0, auto, auto); + } + + &-item { + cursor: pointer; + } +} + +.btn-simple { + & { + color: $color-border-dark; + } + + &:hover, + &.active { + color: $color-text; + } +} + +.user-picture { + & { + @include circle(2.2rem); + } + + &:not([src]) { + @include opacity(0); + } +} + +.content { + & { + cursor: pointer; + } + + &-published { + & { + @include circle(.5rem); + display: inline-block; + border: 0; + background: $color-theme-green; + margin-left: .4rem; + } + + &.unpublished { + background: $color-theme-error; + } + } +} \ No newline at end of file diff --git a/src/Squidex/app/features/content/pages/contents/content-item.component.ts b/src/Squidex/app/features/content/pages/contents/content-item.component.ts new file mode 100644 index 000000000..db275740d --- /dev/null +++ b/src/Squidex/app/features/content/pages/contents/content-item.component.ts @@ -0,0 +1,73 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Sebastian Stehle. All rights reserved + */ + +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +import { + AppComponentBase, + AppLanguageDto, + AppsStoreService, + ContentDto, + fadeAnimation, + FieldDto, + ModalView, + NotificationService, + SchemaDto, + UsersProviderService +} from 'shared'; + +@Component({ + selector: '[sqxContent]', + styleUrls: ['./content-item.component.scss'], + templateUrl: './content-item.component.html', + animations: [ + fadeAnimation + ] +}) +export class ContentItemComponent extends AppComponentBase { + public dropdown = new ModalView(false, true); + + @Output() + public published = new EventEmitter(); + + @Output() + public unpublished = new EventEmitter(); + + @Output() + public deleted = new EventEmitter(); + + @Input() + public fields: FieldDto[]; + + @Input() + public language: AppLanguageDto; + + @Input() + public schema: SchemaDto; + + @Input('sqxContent') + public content: ContentDto; + + constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService) { + super(apps, notifications, users); + } + + public getValue(field: FieldDto): any { + const contentField = this.content.data[field.name]; + + if (!contentField) { + return ''; + } + + if (field.properties.isLocalizable) { + return contentField[this.language.iso2Code]; + } else { + return contentField['iv']; + } + } +} +