@@ -38,8 +38,6 @@ angular.module('mm.addons.mod_glossary')
3838 * @return {Promise } Promise resolved when deleted.
3939 */
4040 self . deleteStoredFiles = function ( glossaryId , entryName , siteId ) {
41- siteId = siteId || $mmSite . getId ( ) ;
42-
4341 return $mmaModGlossaryOffline . getEntryFolder ( glossaryId , entryName , siteId ) . then ( function ( folderPath ) {
4442 return $mmFS . removeDir ( folderPath ) ;
4543 } ) ;
@@ -57,8 +55,6 @@ angular.module('mm.addons.mod_glossary')
5755 * @return {Promise } Promise resolved with the files.
5856 */
5957 self . getStoredFiles = function ( glossaryId , entryName , siteId ) {
60- siteId = siteId || $mmSite . getId ( ) ;
61-
6258 return $mmaModGlossaryOffline . getEntryFolder ( glossaryId , entryName , siteId ) . then ( function ( folderPath ) {
6359 return $mmFileUploaderHelper . getStoredFiles ( folderPath ) ;
6460 } ) ;
@@ -70,12 +66,22 @@ angular.module('mm.addons.mod_glossary')
7066 * @module mm.addons.mod_glossary
7167 * @ngdoc method
7268 * @name $mmaModGlossaryHelper#hasEntryDataChanged
73- * @param {Object } entry Current data.
74- * @param {Object } files Files attached.
69+ * @param {Object } entry Current data.
70+ * @param {Object } files Files attached.
71+ * @param {Object } original Original content.
7572 * @return {Boolean } True if data has changed, false otherwise.
7673 */
77- self . hasEntryDataChanged = function ( entry , files ) {
78- return entry . text || entry . concept || files . length > 0 ;
74+ self . hasEntryDataChanged = function ( entry , files , original ) {
75+ if ( ! original || typeof original . concept == 'undefined' ) {
76+ // There is no original data.
77+ return entry . text || entry . concept || files . length > 0 ;
78+ }
79+
80+ if ( original . text != entry . text || original . concept != entry . concept ) {
81+ return true ;
82+ }
83+
84+ return $mmFileUploaderHelper . areFileListDifferent ( files , original . files ) ;
7985 } ;
8086
8187 /**
@@ -92,8 +98,6 @@ angular.module('mm.addons.mod_glossary')
9298 * @return {Promise } Promise resolved if success, rejected otherwise.
9399 */
94100 self . storeFiles = function ( glossaryId , entryName , files , siteId ) {
95- siteId = siteId || $mmSite . getId ( ) ;
96-
97101 // Get the folder where to store the files.
98102 return $mmaModGlossaryOffline . getEntryFolder ( glossaryId , entryName , siteId ) . then ( function ( folderPath ) {
99103 return $mmFileUploader . storeFilesToUpload ( folderPath , files ) ;
0 commit comments