1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | Object.defineProperty(exports, "__esModule", { value: true });
|
27 | exports.SaveResourceService = void 0;
|
28 | const inversify_1 = require("inversify");
|
29 | const common_1 = require("../common");
|
30 | const navigatable_types_1 = require("./navigatable-types");
|
31 | const saveable_1 = require("./saveable");
|
32 | let SaveResourceService = class SaveResourceService {
|
33 | |
34 |
|
35 |
|
36 | canSave(widget) {
|
37 | return saveable_1.Saveable.isDirty(widget) && (this.canSaveNotSaveAs(widget) || this.canSaveAs(widget));
|
38 | }
|
39 | canSaveNotSaveAs(widget) {
|
40 | var _a;
|
41 |
|
42 | return Boolean(widget && ((_a = navigatable_types_1.NavigatableWidget.getUri(widget)) === null || _a === void 0 ? void 0 : _a.scheme) !== common_1.UNTITLED_SCHEME);
|
43 | }
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 | async save(widget, options) {
|
50 | if (this.canSaveNotSaveAs(widget)) {
|
51 | await saveable_1.Saveable.save(widget, options);
|
52 | }
|
53 | else if (this.canSaveAs(widget)) {
|
54 | await this.saveAs(widget, options);
|
55 | }
|
56 | }
|
57 | canSaveAs(saveable) {
|
58 | return false;
|
59 | }
|
60 | saveAs(sourceWidget, options) {
|
61 | return Promise.reject('Unsupported: The base SaveResourceService does not support saveAs action.');
|
62 | }
|
63 | };
|
64 | __decorate([
|
65 | (0, inversify_1.inject)(common_1.MessageService),
|
66 | __metadata("design:type", common_1.MessageService)
|
67 | ], SaveResourceService.prototype, "messageService", void 0);
|
68 | SaveResourceService = __decorate([
|
69 | (0, inversify_1.injectable)()
|
70 | ], SaveResourceService);
|
71 | exports.SaveResourceService = SaveResourceService;
|
72 |
|
\ | No newline at end of file |