remove ':' from field names
This commit is contained in:
parent
fbfb7861a2
commit
ee3f963919
@ -338,6 +338,8 @@ and notes.mid = ? and cards.ord = ?""",
|
|||||||
|
|
||||||
def renameField(self, m: NoteType, field: Field, newName: Optional[str]) -> None:
|
def renameField(self, m: NoteType, field: Field, newName: Optional[str]) -> None:
|
||||||
self.col.modSchema(check=True)
|
self.col.modSchema(check=True)
|
||||||
|
if newName is not None:
|
||||||
|
newName = newName.replace(":", "")
|
||||||
pat = r"{{([^{}]*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}"
|
pat = r"{{([^{}]*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}"
|
||||||
|
|
||||||
def wrap(txt):
|
def wrap(txt):
|
||||||
|
@ -49,6 +49,7 @@ class CardLayout(QDialog):
|
|||||||
self.emptyFields.append(name)
|
self.emptyFields.append(name)
|
||||||
note[name] = "(%s)" % name
|
note[name] = "(%s)" % name
|
||||||
note.flush()
|
note.flush()
|
||||||
|
self.removeColons()
|
||||||
self.setupTopArea()
|
self.setupTopArea()
|
||||||
self.setupMainArea()
|
self.setupMainArea()
|
||||||
self.setupButtons()
|
self.setupButtons()
|
||||||
@ -242,6 +243,12 @@ Please create a new card type first."""
|
|||||||
)
|
)
|
||||||
self.redraw()
|
self.redraw()
|
||||||
|
|
||||||
|
def removeColons(self):
|
||||||
|
# colons in field names conflict with the template language
|
||||||
|
for fld in self.model["flds"]:
|
||||||
|
if ":" in fld["name"]:
|
||||||
|
self.mm.renameField(self.model, fld, fld["name"])
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user