sp-attachment-library
Version:
This is library is used ro do attachments realted actions on a list item in Sharepoint Angular SPA Addins.
1,030 lines (1,019 loc) • 38 kB
JavaScript
import { sp } from '@pnp/sp';
import { __spread, __values, __awaiter, __generator } from 'tslib';
import * as fa from '@fortawesome/free-solid-svg-icons';
import Swal from 'sweetalert2';
import { InjectionToken, Injectable, Inject, NgModule, defineInjectable, inject, Component, Input } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var SpAttachmentConfigService = new InjectionToken('TestLibConfig');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SpAttachmentLibraryService = /** @class */ (function () {
function SpAttachmentLibraryService(config) {
this.config = config;
// setup sp
sp.setup({
sp: {
headers: {
'Accept': 'application/json;odata=verbose',
},
baseUrl: this.config.baseUrl,
}
});
}
/**
* @param {?} listName
* @param {?} itemId
* @return {?}
*/
SpAttachmentLibraryService.prototype.getAttachmentsById = /**
* @param {?} listName
* @param {?} itemId
* @return {?}
*/
function (listName, itemId) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
/** @type {?} */
var item = sp.web
.lists
.getByTitle(listName)
.items
.getById(itemId);
item.attachmentFiles
.get()
.then((/**
* @param {?} response
* @return {?}
*/
function (response) {
resolve({ result: response });
}))
.catch((/**
* @param {?} e
* @return {?}
*/
function (e) {
reject({ result: false, message: e.message });
}));
}));
};
/**
* @param {?} listName
* @param {?} itemId
* @param {?} attachment
* @return {?}
*/
SpAttachmentLibraryService.prototype.addAttachment = /**
* @param {?} listName
* @param {?} itemId
* @param {?} attachment
* @return {?}
*/
function (listName, itemId, attachment) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
/** @type {?} */
var item = sp.web
.lists
.getByTitle(listName)
.items.getById(itemId);
item.attachmentFiles.add(attachment.name, attachment.content).then((/**
* @param {?} response
* @return {?}
*/
function (response) {
resolve({ result: response });
})).catch((/**
* @param {?} e
* @return {?}
*/
function (e) {
reject({ result: false, message: e.message });
}));
}));
};
/**
* @param {?} listName
* @param {?} itemId
* @param {?} attachments
* @return {?}
*/
SpAttachmentLibraryService.prototype.addAttachments = /**
* @param {?} listName
* @param {?} itemId
* @param {?} attachments
* @return {?}
*/
function (listName, itemId, attachments) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
/** @type {?} */
var item = sp.web
.lists
.getByTitle(listName)
.items.getById(itemId);
item.attachmentFiles.addMultiple(attachments).then((/**
* @param {?} response
* @return {?}
*/
function (response) {
resolve({ result: response });
})).catch((/**
* @param {?} e
* @return {?}
*/
function (e) {
reject({ result: false, message: e.message });
}));
}));
};
/**
* @param {?} listName
* @param {?} itemId
* @param {?} fileName
* @return {?}
*/
SpAttachmentLibraryService.prototype.deleteAttachment = /**
* @param {?} listName
* @param {?} itemId
* @param {?} fileName
* @return {?}
*/
function (listName, itemId, fileName) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
/** @type {?} */
var item = sp.web
.lists
.getByTitle(listName)
.items.getById(itemId);
item.attachmentFiles.getByName(fileName).delete().then((/**
* @param {?} response
* @return {?}
*/
function (response) {
resolve({ result: response });
})).catch((/**
* @param {?} e
* @return {?}
*/
function (e) {
reject({ result: false, message: e.message });
}));
}));
};
/**
* @param {?} listName
* @param {?} itemId
* @param {?} fileNames
* @return {?}
*/
SpAttachmentLibraryService.prototype.deleteAttachments = /**
* @param {?} listName
* @param {?} itemId
* @param {?} fileNames
* @return {?}
*/
function (listName, itemId, fileNames) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
var _a;
/** @type {?} */
var item = sp.web
.lists
.getByTitle(listName)
.items.getById(itemId);
(_a = item.attachmentFiles).deleteMultiple.apply(_a, __spread(fileNames)).then((/**
* @param {?} response
* @return {?}
*/
function (response) {
resolve({ result: response });
})).catch((/**
* @param {?} e
* @return {?}
*/
function (e) {
reject({ result: false, message: e.message });
}));
}));
};
/**
* @param {?} listName
* @param {?} itemId
* @param {?} fileName
* @return {?}
*/
SpAttachmentLibraryService.prototype.getAttachmentContent = /**
* @param {?} listName
* @param {?} itemId
* @param {?} fileName
* @return {?}
*/
function (listName, itemId, fileName) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
/** @type {?} */
var item = sp.web
.lists
.getByTitle(listName)
.items.getById(itemId);
item.attachmentFiles.getByName(fileName).getBlob().then((/**
* @param {?} response
* @return {?}
*/
function (response) {
resolve({ result: response });
})).catch((/**
* @param {?} e
* @return {?}
*/
function (e) {
reject({ result: false, message: e.message });
}));
}));
};
/**
* @param {?} listName
* @param {?} itemId
* @param {?} fileName
* @param {?} content
* @return {?}
*/
SpAttachmentLibraryService.prototype.updateAttachmentContent = /**
* @param {?} listName
* @param {?} itemId
* @param {?} fileName
* @param {?} content
* @return {?}
*/
function (listName, itemId, fileName, content) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
/** @type {?} */
var item = sp.web
.lists
.getByTitle(listName)
.items.getById(itemId);
item.attachmentFiles.getByName(fileName).setContent(content).then((/**
* @param {?} response
* @return {?}
*/
function (response) {
resolve({ result: response });
})).catch((/**
* @param {?} e
* @return {?}
*/
function (e) {
reject({ result: false, message: e.message });
}));
}));
};
SpAttachmentLibraryService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root'
},] }
];
/** @nocollapse */
SpAttachmentLibraryService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: Inject, args: [SpAttachmentConfigService,] }] }
]; };
/** @nocollapse */ SpAttachmentLibraryService.ngInjectableDef = defineInjectable({ factory: function SpAttachmentLibraryService_Factory() { return new SpAttachmentLibraryService(inject(SpAttachmentConfigService)); }, token: SpAttachmentLibraryService, providedIn: "root" });
return SpAttachmentLibraryService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var blobUtil = require('blob-util');
/** @type {?} */
var fileToBlob = (/**
* @param {?} file
* @return {?}
*/
function (file) {
/** @type {?} */
var dataUrl = file.content;
return blobUtil.dataURLToBlob(dataUrl);
});
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SpAttachmentLibraryComponent = /** @class */ (function () {
function SpAttachmentLibraryComponent(spAttachmentLibraryService) {
this.spAttachmentLibraryService = spAttachmentLibraryService;
this.attachments = [];
this.unUpLoadedItems = 0;
this.fa = fa;
this.deleteSwalOptions = {
title: 'Do you really want to delete this attachment?',
type: 'warning',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keep it',
showCancelButton: 'true',
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger ml-sm-2'
}
};
this.deleteAllSwalOptions = {
title: 'Do you really want to delete all selected attachments?',
message: 'All selected attachments added to this list item will be deleted.',
type: 'warning',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keep it',
showCancelButton: 'true',
customClass: {
confirmButton: 'btn btn-danger',
cancelButton: 'btn btn-success ml-sm-2'
}
};
}
Object.defineProperty(SpAttachmentLibraryComponent.prototype, "listName", {
set: /**
* @param {?} listName
* @return {?}
*/
function (listName) {
this._listName = listName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpAttachmentLibraryComponent.prototype, "itemId", {
set: /**
* @param {?} itemId
* @return {?}
*/
function (itemId) {
this._itemId = itemId;
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if (this._listName && this._itemId) {
this.loadExistingFiles();
}
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.loadExistingFiles = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var unuploaded = this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return !x.isSelected && x.serverRelativeUrl === null; }));
this.spAttachmentLibraryService.getAttachmentsById(this._listName, this._itemId).then((/**
* @param {?} data
* @return {?}
*/
function (data) {
var _a;
_this.attachments = [];
data.result.forEach((/**
* @param {?} element
* @return {?}
*/
function (element) {
_this.attachments.push({
fileName: element.FileName,
content: null,
extension: element.FileName.substring(element.FileName.lastIndexOf('.') + 1),
serverRelativeUrl: element.ServerRelativeUrl,
isUploaded: false,
isContentChanged: false,
isLoading: false,
isSelected: false,
});
}));
(_a = _this.attachments).push.apply(_a, __spread(unuploaded));
}));
};
/**
* @param {?} event
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.onAttachmentAdded = /**
* @param {?} event
* @return {?}
*/
function (event) {
var _this = this;
var e_1, _a;
var _loop_1 = function (file) {
if (this_1.attachments.findIndex((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.fileName === file.name; })) < 0) {
this_1.getBase64(file)
.then((/**
* @param {?} response
* @return {?}
*/
function (response) {
_this.attachments.push({
fileName: (/** @type {?} */ (file.name)),
content: (/** @type {?} */ (response)),
extension: file.name.substring(file.name.lastIndexOf('.') + 1),
serverRelativeUrl: null,
isUploaded: false,
isContentChanged: false,
isLoading: false,
isSelected: false,
});
}));
}
else {
this_1.promptReplace(file);
}
};
var this_1 = this;
try {
for (var _b = __values(event.target.files), _c = _b.next(); !_c.done; _c = _b.next()) {
var file = _c.value;
_loop_1(file);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
/**
* @param {?} file
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.promptReplace = /**
* @param {?} file
* @return {?}
*/
function (file) {
var _this = this;
/** @type {?} */
var replaceContentSwal = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger ml-sm-2'
},
buttonsStyling: false,
});
replaceContentSwal.fire({
title: 'File already exists. Do you want to replace it?',
text: 'The file content will be replaced',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, replace it!',
cancelButtonText: 'No, keep it'
}).then((/**
* @param {?} result
* @return {?}
*/
function (result) {
if (result.value) {
_this.getBase64(file)
.then((/**
* @param {?} response
* @return {?}
*/
function (response) {
/** @type {?} */
var exitingFileIndex = _this.attachments.findIndex((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.fileName === file.name; }));
/** @type {?} */
var existingItem = _this.attachments.find((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.fileName === file.name; }));
existingItem.content = (/** @type {?} */ (response));
existingItem.extension = file.name.substring(file.name.lastIndexOf('.') + 1);
existingItem.isContentChanged = true;
existingItem.isUploaded = false;
_this.attachments.splice(exitingFileIndex, 1, existingItem);
}));
}
else if (result.dismiss === Swal.DismissReason.cancel) {
Swal.fire('Cancelled');
}
}));
};
/**
* @param {?} event
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.resetFiles = /**
* @param {?} event
* @return {?}
*/
function (event) {
event.target.value = null;
};
/**
* @param {?} file
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.removeAttachment = /**
* @param {?} file
* @return {?}
*/
function (file) {
var _this = this;
file.isLoading = true;
if (!file.serverRelativeUrl) {
/** @type {?} */
var index = this.attachments.findIndex((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.fileName === file.fileName; }));
file.isLoading = false;
this.attachments.splice(index, 1);
}
else {
file.isLoading = true;
this.spAttachmentLibraryService.deleteAttachment(this._listName, this._itemId, file.fileName).then((/**
* @param {?} data
* @return {?}
*/
function (data) {
/** @type {?} */
var index = _this.attachments.findIndex((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.fileName === file.fileName; }));
file.isLoading = false;
_this.attachments.splice(index, 1);
})).catch((/**
* @param {?} error
* @return {?}
*/
function (error) {
console.log(error);
}));
}
};
/**
* @param {?} file
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.uploadAttachment = /**
* @param {?} file
* @return {?}
*/
function (file) {
var _this = this;
file.isLoading = true;
this._selectedUploadAttachment = {
content: fileToBlob(file),
name: file.fileName
};
this.spAttachmentLibraryService.addAttachment(this._listName, this._itemId, this._selectedUploadAttachment).then((/**
* @param {?} data
* @return {?}
*/
function (data) {
file.isLoading = false;
/** @type {?} */
var fileIndex = _this.attachments.findIndex((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.fileName === file.fileName; }));
_this.attachments[fileIndex].serverRelativeUrl = data.result.data.ServerRelativeUrl;
_this.attachments[fileIndex].isContentChanged = false;
})).catch((/**
* @param {?} error
* @return {?}
*/
function (error) {
console.log(error);
}));
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.hasNewUnUploadedAndSelcted = /**
* @return {?}
*/
function () {
return this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.serverRelativeUrl === null && x.isSelected; })).length > 0;
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.getUnUploadedCount = /**
* @return {?}
*/
function () {
return this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.serverRelativeUrl === null && x.isSelected; })).length;
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.hasSelected = /**
* @return {?}
*/
function () {
return this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.isSelected; })).length > 0;
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.allSelected = /**
* @return {?}
*/
function () {
return this.attachments.every((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.isSelected; }));
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.getSelectedCount = /**
* @return {?}
*/
function () {
return this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.isSelected; })).length;
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.markOrUnMarkAll = /**
* @return {?}
*/
function () {
this.attachments.forEach((/**
* @param {?} e
* @return {?}
*/
function (e) {
e.isSelected = e.isSelected ? false : true;
}));
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.uploadNewAttachments = /**
* @return {?}
*/
function () {
var _this = this;
var e_2, _a;
/** @type {?} */
var newAttachments = Array();
/** @type {?} */
var newlyAddedAttachments = this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.serverRelativeUrl === null && x.isSelected; }));
newlyAddedAttachments.forEach((/**
* @param {?} x
* @return {?}
*/
function (x) {
x.isLoading = true;
}));
/** @type {?} */
var promises = [];
try {
for (var newlyAddedAttachments_1 = __values(newlyAddedAttachments), newlyAddedAttachments_1_1 = newlyAddedAttachments_1.next(); !newlyAddedAttachments_1_1.done; newlyAddedAttachments_1_1 = newlyAddedAttachments_1.next()) {
var attachment = newlyAddedAttachments_1_1.value;
promises.push(fileToBlob(attachment));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (newlyAddedAttachments_1_1 && !newlyAddedAttachments_1_1.done && (_a = newlyAddedAttachments_1.return)) _a.call(newlyAddedAttachments_1);
}
finally { if (e_2) throw e_2.error; }
}
Promise.all(promises).then((/**
* @param {?} attachmentBlobs
* @return {?}
*/
function (attachmentBlobs) {
attachmentBlobs.forEach((/**
* @param {?} blob
* @param {?} index
* @return {?}
*/
function (blob, index) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, newAttachments.push({
name: (newlyAddedAttachments[index].fileName),
content: blob
})];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); }));
_this.spAttachmentLibraryService.addAttachments(_this._listName, _this._itemId, newAttachments).then((/**
* @param {?} data
* @return {?}
*/
function (data) {
_this.loadExistingFiles();
})).catch((/**
* @param {?} error
* @return {?}
*/
function (error) {
console.log(error);
}));
})).catch((/**
* @param {?} error
* @return {?}
*/
function (error) {
console.log(error);
}));
};
/**
* @param {?} file
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.replaceAttachment = /**
* @param {?} file
* @return {?}
*/
function (file) {
var _this = this;
file.isLoading = true;
this.spAttachmentLibraryService.deleteAttachment(this._listName, this._itemId, file.fileName).then((/**
* @param {?} data
* @return {?}
*/
function (data) {
file.isLoading = false;
_this.uploadAttachment(file);
})).catch((/**
* @param {?} error
* @return {?}
*/
function (error) {
console.log(error);
}));
};
/**
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.deleteSelected = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var selectedLocalAttachments = this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.isSelected && x.serverRelativeUrl === null; }));
this.attachments.forEach((/**
* @param {?} e
* @return {?}
*/
function (e) {
e.isLoading = e.isSelected ? true : false;
}));
selectedLocalAttachments.forEach((/**
* @param {?} e
* @return {?}
*/
function (e) {
/** @type {?} */
var index = _this.attachments.findIndex((/**
* @param {?} a
* @return {?}
*/
function (a) { return a.fileName === e.fileName; }));
_this.attachments.splice(index, 1);
}));
/** @type {?} */
var serverFiles = this.attachments.filter((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.serverRelativeUrl !== null && x.isSelected; }));
this.attachments.forEach((/**
* @param {?} e
* @return {?}
*/
function (e) {
e.isLoading = e.isSelected ? true : false;
}));
/** @type {?} */
var fileNames = serverFiles.map((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.fileName; }));
this.spAttachmentLibraryService.deleteAttachments(this._listName, this._itemId, fileNames).then((/**
* @param {?} data
* @return {?}
*/
function (data) {
_this.loadExistingFiles();
})).catch((/**
* @param {?} error
* @return {?}
*/
function (error) {
console.log(error);
}));
};
/**
* @param {?} file
* @return {?}
*/
SpAttachmentLibraryComponent.prototype.getBase64 = /**
* @param {?} file
* @return {?}
*/
function (file) {
return new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
/** @type {?} */
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (/**
* @return {?}
*/
function () { return resolve(reader.result); });
reader.onerror = (/**
* @param {?} error
* @return {?}
*/
function (error) { return reject(error); });
}));
};
SpAttachmentLibraryComponent.decorators = [
{ type: Component, args: [{
selector: 'sp-attachment',
template: "<div class=\"container\">\r\n <h4>Attachments</h4>\r\n <div class=\"row\">\r\n <div class=\"col-md-12\">\r\n <div class=\"form-group\">\r\n <label class=\"control-label\">Attachments</label>\r\n <input type=\"file\" multiple size=\"50\" class=\"custom-file-input\" id=\"customFile\" name=\"filename\"\r\n base-sixty-four-input (click)=\"resetFiles($event)\" (input)=\"onAttachmentAdded($event)\">\r\n <label class=\"custom-file-label\" for=\"customFile\">choose your attachments</label>\r\n <ul class=\"list-group\">\r\n <li class=\"list-group-item\">\r\n <div class=\"row\">\r\n <div class=\"col-md-8 pull-left\">Files</div>\r\n <div class=\"col-md-4 pull-right\">Actions</div>\r\n </div>\r\n </li>\r\n </ul>\r\n <ul class=\"list-group\" *ngFor=\"let attachment of attachments\">\r\n <li *ngIf=\"!attachment.isLoading\" class=\"list-group-item\">\r\n <div class=\"row\">\r\n <div class=\"col-md-8 pull-left\">\r\n <div class=\"form-check\">\r\n <input type=\"checkbox\" [(ngModel)]=\"attachment.isSelected\" class=\"form-check-input\" id=\"{{ attachment.fileName }}\">\r\n </div>\r\n <a class=\"ml-sm-3\" href=\"{{ attachment.serverRelativeUrl }}\" target=\"_blank\">\r\n {{attachment.fileName}}\r\n </a>\r\n </div>\r\n <div class=\"col-md-4 pull-right\">\r\n <button class=\"btn btn-danger btn-xs\" [swal]=\"deleteSwalOptions\"\r\n (confirm)=\"removeAttachment(attachment)\">\r\n <fa-icon [icon]=\"fa.faTrash\"></fa-icon>\r\n </button>\r\n <button *ngIf=\"!attachment.serverRelativeUrl\" class=\"btn btn-primary btn-xs ml-sm-2\"\r\n (click)=\"uploadAttachment(attachment)\">\r\n <fa-icon [icon]=\"fa.faUpload\"></fa-icon>\r\n </button>\r\n <button *ngIf=\"attachment.isContentChanged\" class=\"btn btn-primary btn-xs ml-sm-2\"\r\n (click)=\"replaceAttachment(attachment)\">\r\n <fa-icon [icon]=\"fa.faEdit\"></fa-icon>\r\n </button>\r\n </div>\r\n </div>\r\n </li>\r\n <li *ngIf=\"attachment.isLoading\" class=\"list-group-item animated-background\">\r\n </li>\r\n </ul>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"row\">\r\n <div class=\"col-md-12\" *ngIf=\"attachments.length > 0\">\r\n <button type=\"button\" class=\"btn btn-info btn-sm ml-sm-2\"\r\n (click)=\"markOrUnMarkAll()\">\r\n {{ allSelected() ? 'Unmark All' : 'Mark All'}}\r\n </button>\r\n <button *ngIf=\"hasNewUnUploadedAndSelcted()\" type=\"button\" class=\"btn btn-success btn-sm ml-sm-2\"\r\n (click)=\"uploadNewAttachments()\">\r\n Upload Selected({{ getUnUploadedCount() }})\r\n </button>\r\n <button *ngIf=\"hasSelected()\" type=\"button\" class=\"btn btn-danger btn-sm ml-sm-2\" [swal]=\"deleteAllSwalOptions\"\r\n (confirm)=\"deleteSelected()\">Delete Selected({{ getSelectedCount() }})\r\n </button>\r\n </div>\r\n </div>\r\n</div>",
styles: [".btn-group-xs>.btn,.btn-xs{padding:.25rem .4rem;font-size:.875rem;line-height:.5;border-radius:.2rem}.loader-container{margin:0 auto;width:400px;max-width:90%;display:flex;flex-direction:column;justify-content:center;align-items:center}@-webkit-keyframes placeholder{0%{background-position:-600px 0}100%{background-position:600px 0}}@keyframes placeholder{0%{background-position:-600px 0}100%{background-position:600px 0}}.animated-background{-webkit-animation-duration:1s;animation-duration:1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:placeholder;animation-name:placeholder;-webkit-animation-timing-function:linear;animation-timing-function:linear;background:#eee;background:linear-gradient(to right,#eee 8%,#ddd 18%,#eee 33%);background-size:1200px 100px;min-height:30px;width:100%;margin:5px 0;border-radius:3px}"]
}] }
];
/** @nocollapse */
SpAttachmentLibraryComponent.ctorParameters = function () { return [
{ type: SpAttachmentLibraryService }
]; };
SpAttachmentLibraryComponent.propDecorators = {
listName: [{ type: Input }],
itemId: [{ type: Input }]
};
return SpAttachmentLibraryComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SpAttachmentLibraryModule = /** @class */ (function () {
function SpAttachmentLibraryModule() {
}
/**
* @param {?} config
* @return {?}
*/
SpAttachmentLibraryModule.forRoot = /**
* @param {?} config
* @return {?}
*/
function (config) {
return {
ngModule: SpAttachmentLibraryModule,
providers: [
SpAttachmentLibraryService,
{
provide: SpAttachmentConfigService,
useValue: config
}
]
};
};
SpAttachmentLibraryModule.decorators = [
{ type: NgModule, args: [{
declarations: [SpAttachmentLibraryComponent],
imports: [
BrowserModule,
FormsModule,
SweetAlert2Module.forRoot({
buttonsStyling: false,
customClass: 'modal-content',
confirmButtonClass: 'btn btn-primary',
cancelButtonClass: 'btn'
}),
FontAwesomeModule,
],
exports: [SpAttachmentLibraryComponent]
},] }
];
return SpAttachmentLibraryModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { SpAttachmentLibraryService, SpAttachmentLibraryComponent, SpAttachmentLibraryModule, SpAttachmentConfigService, SpAttachmentConfigService as ɵa };
//# sourceMappingURL=sp-attachment-library.js.map