mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix bug
This commit is contained in:
@@ -231,87 +231,12 @@ export class ViewPublicationsPage implements OnInit {
|
||||
this.showLoader = true;
|
||||
const folderId = this.folderId
|
||||
|
||||
try {
|
||||
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
|
||||
await this.publicationFolderService.getPublicationsIds(folderId)
|
||||
|
||||
this.createPublicationList(folderId)
|
||||
let loadLater = []
|
||||
for (let publicationId of publicationIds) {
|
||||
|
||||
if (!this.publicationIsPresent(publicationId, folderId)) {
|
||||
await this.loadPublication(publicationId, folderId)
|
||||
|
||||
} else {
|
||||
loadLater.push(publicationId)
|
||||
}
|
||||
}
|
||||
|
||||
for (let publicationId of loadLater) {
|
||||
await this.loadPublication(publicationId, folderId)
|
||||
}
|
||||
|
||||
for (let localPublication of this.publicationFolderService.publicationList[folderId]) {
|
||||
|
||||
const apiPublication = publicationIds.includes(localPublication.DocumentId)
|
||||
if (!apiPublication) {
|
||||
this.publicationFolderService.deletePost(folderId, localPublication.DocumentId)
|
||||
}
|
||||
}
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
this.storage.set(folderId, this.publicationFolderService.publicationList[folderId]);
|
||||
this.getpublication = this.publicationFolderService.publicationList[folderId];
|
||||
} catch (error) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
this.showLoader = false;
|
||||
|
||||
}
|
||||
|
||||
publicationIsPresent(publicationId, folderId) {
|
||||
return this.publicationFolderService.publicationList[folderId].find(e => e.DocumentId == publicationId)
|
||||
}
|
||||
publicationFind(publicationId, folderId) {
|
||||
return this.publicationFolderService.publicationList[folderId].find(e => e.DocumentId == publicationId)
|
||||
}
|
||||
publicationFindIndex(publicationId, folderId) {
|
||||
return this.publicationFolderService.publicationList[folderId].findIndex(e => e.DocumentId == publicationId)
|
||||
}
|
||||
|
||||
async loadPublication(publicationId, folderId) {
|
||||
let Publication = await this.publications.GetPublicationWithArrayOfFilesById(publicationId).toPromise();
|
||||
console.log('Publications with array of file: ', Publication.Files)
|
||||
this.arrayOfFile = Publication.Files
|
||||
let publicationDetails: Publication = this.publicationPipe.itemList(Publication)
|
||||
|
||||
const findIndex = this.publicationFindIndex(publicationId, folderId)
|
||||
const found = this.publicationIsPresent(publicationId, folderId)
|
||||
|
||||
|
||||
|
||||
if (!found) {
|
||||
this.publicationFolderService.publicationList[folderId].push(publicationDetails)
|
||||
this.publicationFolderService.revertPublicationOrder(folderId)
|
||||
} else {
|
||||
|
||||
|
||||
let a: any = Object.assign({}, this.publicationFolderService.publicationList[folderId][findIndex])
|
||||
let b: any = Object.assign({}, publicationDetails)
|
||||
|
||||
a.Files = a.Files.length
|
||||
b.Files = b.Files.length
|
||||
|
||||
if (JSON.stringify(a) != JSON.stringify(b)) {
|
||||
|
||||
// console.log({a, b})
|
||||
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
|
||||
} else {
|
||||
// console.log({publicationDetails})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async AddPublication(publicationType: any, folderId: any) {
|
||||
|
||||
@@ -397,4 +322,3 @@ export class ViewPublicationsPage implements OnInit {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ export class NewPublicationPage implements OnInit {
|
||||
FileType: this.checkFileType.checkFileType( this.removeTextBeforeSlash(element.mimeType, '/')) as any
|
||||
})
|
||||
|
||||
/* fileObject.needUpload() */
|
||||
fileObject.needUpload()
|
||||
this.PublicationFromMvService.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
@@ -380,6 +380,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
|
||||
close() {
|
||||
this.PublicationFromMvService.form.cancel = true
|
||||
if(this.PublicationFromMvService.form.send == false) {
|
||||
this.PublicationFromMvService.cancel()
|
||||
this.PublicationFromMvService.ObjectMergeNotification.close()
|
||||
@@ -765,38 +766,18 @@ console.log(stringGerada);
|
||||
return stringAleatoria;
|
||||
}
|
||||
|
||||
async showCroppModal() {
|
||||
const modal = await this.modalController.create({
|
||||
component: CropImagePage,
|
||||
componentProps: {
|
||||
base64ToCroppe: this.capturedImage
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
async showCroppModal() {
|
||||
|
||||
modal.onDidDismiss().then((res) => {
|
||||
if (res) {
|
||||
this.capturedImage = res.data
|
||||
this.filecontent = true;
|
||||
this.photoOrVideo = false;
|
||||
|
||||
const newAttachment = new PublicationAttachmentEntity(
|
||||
{
|
||||
base64: res.data.base64ToCroppe,
|
||||
extension: 'jpeg',
|
||||
OriginalFileName: "image",
|
||||
FileType: 'image'
|
||||
}
|
||||
)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: this.removeTextBeforeSlash(this.capturedImage, ',') ,
|
||||
extension: 'jpeg',
|
||||
OriginalFileName: 'video',
|
||||
FileType: 'image'
|
||||
})
|
||||
this.PublicationFromMvService.form.Files.push(fileObject)
|
||||
|
||||
this.PublicationFromMvService.form.Files.push(newAttachment)
|
||||
}
|
||||
}, (error) => {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
await modal.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ export class PublicationFromMvService {
|
||||
publication.DocumentId = null;
|
||||
publication.ProcessId = this.folderId
|
||||
|
||||
if(this.form.cancel == false) {
|
||||
if(this.form.cancel == true) {
|
||||
window['upload-header-set-remove'](this.id);
|
||||
return false
|
||||
}
|
||||
@@ -211,7 +211,6 @@ export class PublicationFromMvService {
|
||||
try {
|
||||
|
||||
await this.publications.CreatePublication(publication.ProcessId, publication).toPromise()
|
||||
|
||||
if (this.publicationType == '1') {
|
||||
this.httpErroHandle.httpsSucessMessagge('Criar publicação')
|
||||
} else if (this.publicationType == '2') {
|
||||
|
||||
@@ -131,6 +131,15 @@ export class PublicationFolderService {
|
||||
await this.loadPublication(publicationId, folderId)
|
||||
}
|
||||
|
||||
for (let localPublication of this.publicationList[folderId]) {
|
||||
|
||||
const apiPublication = publicationIds.includes(localPublication.DocumentId)
|
||||
if (!apiPublication) {
|
||||
this.deletePost(folderId, localPublication.DocumentId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
this.storage.set(folderId, this.publicationList[folderId]);
|
||||
@@ -161,7 +170,7 @@ export class PublicationFolderService {
|
||||
|
||||
if (JSON.stringify(a) != JSON.stringify(b)) {
|
||||
|
||||
// console.log({a, b})
|
||||
console.log({a, b})
|
||||
this.publicationList[folderId][findIndex] = publicationDetails
|
||||
} else {
|
||||
// console.log({publicationDetails})
|
||||
@@ -203,7 +212,7 @@ export class PublicationFolderService {
|
||||
if (!found) {
|
||||
this.publicationList[folderId].push(publicationDetails)
|
||||
this.revertPublicationOrder(folderId);
|
||||
|
||||
|
||||
} else {
|
||||
return this.publicationList[folderId][findIndex]
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@ import { environment as oaprProd } from './suport/oapr'
|
||||
import { DevDev } from './suport/dev'
|
||||
|
||||
|
||||
export const environment: Environment = oaprProd;
|
||||
export const environment: Environment = DevDev;
|
||||
|
||||
Reference in New Issue
Block a user